robot-1.4: Simulate keyboard and mouse events

Safe HaskellNone
LanguageHaskell98

Test.Robot

Contents

Description

The main Robot interface.

Synopsis

Running your robot

data Robot a Source

A Robot is a program that interacts with the GUI.

Use runRobot to execute your Robot, and liftIO to perform arbitrary I/O.

runRobot :: Robot a -> IO a Source

Run the robot, connecting to the display automatically.

Key and button constants

Doing things

class Pressable x where Source

Represents things that can be pressed: either a single Switch or a list of Switches.

Minimal complete definition

press, release

Methods

press :: x -> Robot () Source

Press a key or button.

release :: x -> Robot () Source

Release a key or button.

hold :: x -> Robot a -> Robot a infixr 4 Source

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 Switch 
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.

Note that the underlying events are fired very quickly; much faster than some applications (such as Xmonad) can handle. If this becomes an issue, you may introduce a delay using sleep:

slowTap x = x `hold` sleep 0.1

Miscellaneous

sleep :: Rational -> Robot () Source

Do nothing for the specified number of seconds.