robot-1.2: Simulate keyboard and mouse events

Safe HaskellNone

Test.Robot

Contents

Description

The main Robot interface.

Synopsis

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

class Pressable x whereSource

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

Methods

press :: x -> Robot ()Source

Press a key or button.

release :: x -> Robot ()Source

Release a key or button.

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

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

 press x >> act >> release x

except hold ensures that the argument is released in the event of an exception.

Instances

Pressable Button 
Pressable Key 
Pressable x => Pressable [x]

Press items from left-to-right, but release from right-to-left.

This behavior ensures the following equivalence holds:

 press xs >> act >> release xs
   === xs `hold` act
   === x1 `hold` x2 `hold` ... xn `hold` act

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.

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

Press the argument, then release it.

Miscellaneous

sleep :: Rational -> Robot ()Source

Do nothing for the specified number of seconds.