robot-1.1: Simulate keyboard and mouse events

Safe HaskellNone




The main Robot interface.


Running your robot

data Robot a Source

The Robot monad: a reader monad over IO.

runRobot :: Robot a -> IO aSource

Run the robot, connecting to the display automatically.

runRobotWithConnection :: Robot a -> Connection -> IO aSource

Run the robot using an existing connection.

Key and button constants

Doing things

Basic operations

class Pressable x whereSource

Represents things that can be pressed: either a key on a keyboard or a button on a mouse.


press :: x -> Robot ()Source

Press a key or button.

release :: x -> Robot ()Source

Release a key or button.

moveBy :: Int -> Int -> Robot ()Source

Move the pointer by an offset.

moveTo :: Int -> Int -> Robot ()Source

Move the pointer to a point on the screen.

Derived operations

hold :: Pressable x => x -> Robot a -> Robot aSource

hold x act holds down x while executing act. It is equivalent to the code:

 press x
 release x

For example, you type some text in ALL CAPS using:

 hold _Shift $ mapM_ tap [_D, _U, _C, _K, _S]

tap :: Pressable x => x -> Robot ()Source

Press the argument, then release it.


sleep :: Rational -> Robot ()Source

Do nothing for the specified number of seconds.