module Test.Robot
(
Robot()
, runRobot
, runRobotWithConnection
, module Test.Robot.Types
, Pressable(press, release)
, moveBy
, moveTo
, hold
, tap
, sleep
) where
import Control.Applicative
import Control.Concurrent (threadDelay)
import Control.Monad.IO.Class
import Test.Robot.Internal
import Test.Robot.Types
class Pressable x where
press :: x -> Robot ()
release :: x -> Robot ()
instance Pressable Key where
press = keyboard True
release = keyboard False
instance Pressable Button where
press = button True
release = button False
moveBy :: Int -> Int -> Robot ()
moveBy = motion True
moveTo :: Int -> Int -> Robot ()
moveTo = motion False
hold :: Pressable x => x -> Robot a -> Robot a
hold = bracketRobot_ <$> press <*> release
tap :: Pressable x => x -> Robot ()
tap = (`hold` return ())
sleep :: Rational -> Robot ()
sleep = liftIO . threadDelay . round . (* 1000000)