packages feed

robot 1.3.0.1 → 1.4

raw patch · 8 files changed

+213/−233 lines, 8 filesdep ~exceptions

Dependency ranges changed: exceptions

Files

README.markdown view
@@ -32,3 +32,15 @@     cabal install  Now try running some of the programs in the `examples` directory.+++TODO+----++* Backends for Mac OS X, Windows, and Wayland++* Screenshots++* Actions currently run instantaneously, which can be an issue for some+  applications. Perhaps add a small delay between each operation like+  Java does.
Test/Robot.hs view
@@ -35,8 +35,8 @@ infixr 4 `hold`  -- Allow e.g. xs ++ ys `hold` m  --- | Represents things that can be pressed: either a key on a keyboard--- or a button on a mouse.+-- | Represents things that can be pressed: either a single 'Switch' or+-- a list of 'Switch'es. class Pressable x where      -- | Press a key or button.@@ -58,13 +58,9 @@     hold :: x -> Robot a -> Robot a     hold = bracket_ <$> press <*> release -instance Pressable Key where-    press = keyboard True-    release = keyboard False--instance Pressable Button where-    press = button True-    release = button False+instance Pressable Switch where+    press = switch True+    release = switch False  -- | Press items from left-to-right, but release from right-to-left. --
Test/Robot/Internal.hs view
@@ -14,8 +14,7 @@     , mkRobot'        -- * Synthesizing events-    , keyboard-    , button+    , switch     , motion      ) where@@ -68,16 +67,14 @@ mkRobot' = mkRobot . (. fst)  -keyboard :: Bool -> Key -> Robot ()-keyboard press key = mkRobot $ \(c, keymap) -> do-    case M.lookup (rawKey key) keymap of-        Nothing -> error $ "keysym " ++ show (rawKey key)+switch :: Bool -> Switch -> Robot ()+switch press (Key key) = mkRobot $ \(c, keymap) -> do+    case M.lookup key keymap of+        Nothing -> error $ "keysym " ++ show key                             ++ " does not exist on keyboard layout"         Just keycode -> X.keyboard c press keycode--button :: Bool -> Button -> Robot ()-button press butt {- LOL -} = mkRobot' $ \c ->-    X.button c press (rawButton butt)+switch press (Button butt {- LOL -}) = mkRobot' $ \c ->+    X.button c press butt  motion :: Bool -> Int -> Int -> Robot () motion press x y = mkRobot' $ \c ->
Test/Robot/Types.hs view
@@ -1,20 +1,11 @@--- | Defines the 'Key' and 'Button' types, along with a list of--- constants of those types.+-- | Defines the 'Switch' type, along with some constants and utilities.  module Test.Robot.Types     (       -- * Types-      Key()  -- Hide implementation-    , Button()--      -- ** Creating-      -- $custom-    , customKey-    , customButton--      -- ** Extracting-    , rawKey-    , rawButton+      Switch(..)+      -- ** Defining your own keys+      -- $keys        -- * Constants       -- ** Buttons@@ -26,36 +17,26 @@      ) where -import Graphics.XHB- import Test.Robot.Types.Core import Test.Robot.Types.Keys --- $custom--- These two functions let you define your own keys and buttons.------ 'customKey' requires a magic number (/keysym/) as its argument. On--- most Unix systems, you can look up common keysyms in the file--- @\/usr\/include\/X11\/keysymdef.h@.+-- $keys+-- The 'Key' constructor requires a magic number (/keysym/) as its+-- argument. On most Unix systems, you can look up common keysyms in the+-- file @\/usr\/include\/X11\/keysymdef.h@. -- -- For example, the pound sign @£@ is listed as: -- -- > #define XK_sterling                      0x00a3  /* U+00A3 POUND SIGN */ ----- so to input this key, we use @customKey 0x00a3@.+-- so to input this key, we use @Key 0x00a3@. -- -- Note: this feature only works if the key actually exists on your -- keyboard. If not, then using the result will raise an exception. -customKey :: KEYSYM -> Key-customKey = Key--customButton :: BUTTON -> Button-customButton = Button--leftButton, middleButton, rightButton :: Button-scrollUp, scrollDown, scrollLeft, scrollRight :: Button-backButton, forwardButton :: Button+leftButton, middleButton, rightButton :: Switch+scrollUp, scrollDown, scrollLeft, scrollRight :: Switch+backButton, forwardButton :: Switch [leftButton, middleButton, rightButton,     scrollUp, scrollDown, scrollLeft, scrollRight,     backButton, forwardButton] = map Button [1..9]
Test/Robot/Types/Core.hs view
@@ -2,17 +2,11 @@  import Graphics.XHB (BUTTON, KEYSYM) --- | A key on the keyboard.-newtype Key = Key-    { -- | Retrieve the internal identifier for this key.-      rawKey :: KEYSYM }-    deriving (Eq, Ord, Read, Show)---- | A mouse button or scroll wheel.+-- | Either a key on the keyboard, or a mouse button or scroll wheel. ----- Note that the scroll wheel is treated as two separate buttons: one+-- Note that the scroll wheel is treated as two mouse buttons: one -- scrolling up, and one scrolling down.-newtype Button = Button-    { -- | Retrieve the internal identifier for this button.-      rawButton :: BUTTON }+data Switch+    = Key KEYSYM+    | Button BUTTON     deriving (Eq, Ord, Read, Show)
Test/Robot/Types/Keys.hs view
@@ -209,361 +209,361 @@  import Test.Robot.Types.Core -_Backspace :: Key+_Backspace :: Switch _Backspace                     = Key 0xff08-_Tab :: Key+_Tab :: Switch _Tab                           = Key 0xff09-_LineFeed :: Key+_LineFeed :: Switch _LineFeed                      = Key 0xff0a-_Clear :: Key+_Clear :: Switch _Clear                         = Key 0xff0b-_Return :: Key+_Return :: Switch _Return                        = Key 0xff0d-_Pause :: Key+_Pause :: Switch _Pause                         = Key 0xff13-_ScrollLock :: Key+_ScrollLock :: Switch _ScrollLock                    = Key 0xff14-_SysReq :: Key+_SysReq :: Switch _SysReq                        = Key 0xff15-_Escape :: Key+_Escape :: Switch _Escape                        = Key 0xff1b-_Delete :: Key+_Delete :: Switch _Delete                        = Key 0xffff -_Home :: Key+_Home :: Switch _Home                          = Key 0xff50-_Left :: Key+_Left :: Switch _Left                          = Key 0xff51-_Up :: Key+_Up :: Switch _Up                            = Key 0xff52-_Right :: Key+_Right :: Switch _Right                         = Key 0xff53-_Down :: Key+_Down :: Switch _Down                          = Key 0xff54-_Prior, _PageUp :: Key+_Prior, _PageUp :: Switch _Prior                         = Key 0xff55 _PageUp                        = Key 0xff55-_Next, _PageDown :: Key+_Next, _PageDown :: Switch _Next                          = Key 0xff56 _PageDown                      = Key 0xff56-_End :: Key+_End :: Switch _End                           = Key 0xff57-_Begin :: Key+_Begin :: Switch _Begin                         = Key 0xff58 -_Select :: Key+_Select :: Switch _Select                        = Key 0xff60-_Print :: Key+_Print :: Switch _Print                         = Key 0xff61-_Execute :: Key+_Execute :: Switch _Execute                       = Key 0xff62-_Insert :: Key+_Insert :: Switch _Insert                        = Key 0xff63-_Undo :: Key+_Undo :: Switch _Undo                          = Key 0xff65-_Redo :: Key+_Redo :: Switch _Redo                          = Key 0xff66-_Menu :: Key+_Menu :: Switch _Menu                          = Key 0xff67-_Find :: Key+_Find :: Switch _Find                          = Key 0xff68-_Cancel :: Key+_Cancel :: Switch _Cancel                        = Key 0xff69-_Help :: Key+_Help :: Switch _Help                          = Key 0xff6a-_Break :: Key+_Break :: Switch _Break                         = Key 0xff6b-_ModeSwitch, _ScriptSwitch :: Key+_ModeSwitch, _ScriptSwitch :: Switch _ModeSwitch                    = Key 0xff7e _ScriptSwitch                  = Key 0xff7e-_NumLock :: Key+_NumLock :: Switch _NumLock                       = Key 0xff7f -_KP_Space :: Key+_KP_Space :: Switch _KP_Space                      = Key 0xff80-_KP_Tab :: Key+_KP_Tab :: Switch _KP_Tab                        = Key 0xff89-_KP_Enter :: Key+_KP_Enter :: Switch _KP_Enter                      = Key 0xff8d-_KP_F1 :: Key+_KP_F1 :: Switch _KP_F1                         = Key 0xff91-_KP_F2 :: Key+_KP_F2 :: Switch _KP_F2                         = Key 0xff92-_KP_F3 :: Key+_KP_F3 :: Switch _KP_F3                         = Key 0xff93-_KP_F4 :: Key+_KP_F4 :: Switch _KP_F4                         = Key 0xff94-_KP_Home :: Key+_KP_Home :: Switch _KP_Home                       = Key 0xff95-_KP_Left :: Key+_KP_Left :: Switch _KP_Left                       = Key 0xff96-_KP_Up :: Key+_KP_Up :: Switch _KP_Up                         = Key 0xff97-_KP_Right :: Key+_KP_Right :: Switch _KP_Right                      = Key 0xff98-_KP_Down :: Key+_KP_Down :: Switch _KP_Down                       = Key 0xff99-_KP_Prior, _KP_PageUp :: Key+_KP_Prior, _KP_PageUp :: Switch _KP_Prior                      = Key 0xff9a _KP_PageUp                     = Key 0xff9a-_KP_Next, _KP_PageDown :: Key+_KP_Next, _KP_PageDown :: Switch _KP_Next                       = Key 0xff9b _KP_PageDown                   = Key 0xff9b-_KP_End :: Key+_KP_End :: Switch _KP_End                        = Key 0xff9c-_KP_Begin :: Key+_KP_Begin :: Switch _KP_Begin                      = Key 0xff9d-_KP_Insert :: Key+_KP_Insert :: Switch _KP_Insert                     = Key 0xff9e-_KP_Delete :: Key+_KP_Delete :: Switch _KP_Delete                     = Key 0xff9f-_KP_Multiply :: Key+_KP_Multiply :: Switch _KP_Multiply                   = Key 0xffaa-_KP_Add :: Key+_KP_Add :: Switch _KP_Add                        = Key 0xffab-_KP_Separator :: Key+_KP_Separator :: Switch _KP_Separator                  = Key 0xffac-_KP_Subtract :: Key+_KP_Subtract :: Switch _KP_Subtract                   = Key 0xffad-_KP_Decimal :: Key+_KP_Decimal :: Switch _KP_Decimal                    = Key 0xffae-_KP_Divide :: Key+_KP_Divide :: Switch _KP_Divide                     = Key 0xffaf-_KP_Equal :: Key+_KP_Equal :: Switch _KP_Equal                      = Key 0xffbd -_KP_0 :: Key+_KP_0 :: Switch _KP_0                          = Key 0xffb0-_KP_1 :: Key+_KP_1 :: Switch _KP_1                          = Key 0xffb1-_KP_2 :: Key+_KP_2 :: Switch _KP_2                          = Key 0xffb2-_KP_3 :: Key+_KP_3 :: Switch _KP_3                          = Key 0xffb3-_KP_4 :: Key+_KP_4 :: Switch _KP_4                          = Key 0xffb4-_KP_5 :: Key+_KP_5 :: Switch _KP_5                          = Key 0xffb5-_KP_6 :: Key+_KP_6 :: Switch _KP_6                          = Key 0xffb6-_KP_7 :: Key+_KP_7 :: Switch _KP_7                          = Key 0xffb7-_KP_8 :: Key+_KP_8 :: Switch _KP_8                          = Key 0xffb8-_KP_9 :: Key+_KP_9 :: Switch _KP_9                          = Key 0xffb9 -_F1 :: Key+_F1 :: Switch _F1                            = Key 0xffbe-_F2 :: Key+_F2 :: Switch _F2                            = Key 0xffbf-_F3 :: Key+_F3 :: Switch _F3                            = Key 0xffc0-_F4 :: Key+_F4 :: Switch _F4                            = Key 0xffc1-_F5 :: Key+_F5 :: Switch _F5                            = Key 0xffc2-_F6 :: Key+_F6 :: Switch _F6                            = Key 0xffc3-_F7 :: Key+_F7 :: Switch _F7                            = Key 0xffc4-_F8 :: Key+_F8 :: Switch _F8                            = Key 0xffc5-_F9 :: Key+_F9 :: Switch _F9                            = Key 0xffc6-_F10 :: Key+_F10 :: Switch _F10                           = Key 0xffc7-_F11 :: Key+_F11 :: Switch _F11                           = Key 0xffc8-_F12 :: Key+_F12 :: Switch _F12                           = Key 0xffc9-_F13 :: Key+_F13 :: Switch _F13                           = Key 0xffca-_F14 :: Key+_F14 :: Switch _F14                           = Key 0xffcb-_F15 :: Key+_F15 :: Switch _F15                           = Key 0xffcc-_F16 :: Key+_F16 :: Switch _F16                           = Key 0xffcd-_F17 :: Key+_F17 :: Switch _F17                           = Key 0xffce-_F18 :: Key+_F18 :: Switch _F18                           = Key 0xffcf-_F19 :: Key+_F19 :: Switch _F19                           = Key 0xffd0 -_Shift, _Shift_L :: Key+_Shift, _Shift_L :: Switch _Shift                         = Key 0xffe1 _Shift_L                       = Key 0xffe1-_Shift_R :: Key+_Shift_R :: Switch _Shift_R                       = Key 0xffe2-_Ctrl, _Control, _Control_L :: Key+_Ctrl, _Control, _Control_L :: Switch _Ctrl                          = Key 0xffe3 _Control                       = Key 0xffe3 _Control_L                     = Key 0xffe3-_Control_R :: Key+_Control_R :: Switch _Control_R                     = Key 0xffe4-_CapsLock :: Key+_CapsLock :: Switch _CapsLock                      = Key 0xffe5-_ShiftLock :: Key+_ShiftLock :: Switch _ShiftLock                     = Key 0xffe6 -_Meta, _Meta_L :: Key+_Meta, _Meta_L :: Switch _Meta                          = Key 0xffe7 _Meta_L                        = Key 0xffe7-_Meta_R :: Key+_Meta_R :: Switch _Meta_R                        = Key 0xffe8-_Alt, _Alt_L :: Key+_Alt, _Alt_L :: Switch _Alt                           = Key 0xffe9 _Alt_L                         = Key 0xffe9-_Alt_R :: Key+_Alt_R :: Switch _Alt_R                         = Key 0xffea-_Super, _Super_L :: Key+_Super, _Super_L :: Switch _Super                         = Key 0xffeb _Super_L                       = Key 0xffeb-_Super_R :: Key+_Super_R :: Switch _Super_R                       = Key 0xffec-_Hyper, _Hyper_L :: Key+_Hyper, _Hyper_L :: Switch _Hyper                         = Key 0xffed _Hyper_L                       = Key 0xffed-_Hyper_R :: Key+_Hyper_R :: Switch _Hyper_R                       = Key 0xffee -_Space :: Key+_Space :: Switch _Space                         = Key 0x0020-_Exclamation :: Key+_Exclamation :: Switch _Exclamation                   = Key 0x0021-_Quotation :: Key+_Quotation :: Switch _Quotation                     = Key 0x0022-_NumberSign :: Key+_NumberSign :: Switch _NumberSign                    = Key 0x0023-_Dollar :: Key+_Dollar :: Switch _Dollar                        = Key 0x0024-_Percent :: Key+_Percent :: Switch _Percent                       = Key 0x0025-_Ampersand :: Key+_Ampersand :: Switch _Ampersand                     = Key 0x0026-_Apostrophe :: Key+_Apostrophe :: Switch _Apostrophe                    = Key 0x0027-_ParenLeft :: Key+_ParenLeft :: Switch _ParenLeft                     = Key 0x0028-_ParenRight :: Key+_ParenRight :: Switch _ParenRight                    = Key 0x0029-_Asterisk :: Key+_Asterisk :: Switch _Asterisk                      = Key 0x002a-_Plus :: Key+_Plus :: Switch _Plus                          = Key 0x002b-_Comma :: Key+_Comma :: Switch _Comma                         = Key 0x002c-_Minus :: Key+_Minus :: Switch _Minus                         = Key 0x002d-_Period :: Key+_Period :: Switch _Period                        = Key 0x002e-_Slash :: Key+_Slash :: Switch _Slash                         = Key 0x002f-_0 :: Key+_0 :: Switch _0                             = Key 0x0030-_1 :: Key+_1 :: Switch _1                             = Key 0x0031-_2 :: Key+_2 :: Switch _2                             = Key 0x0032-_3 :: Key+_3 :: Switch _3                             = Key 0x0033-_4 :: Key+_4 :: Switch _4                             = Key 0x0034-_5 :: Key+_5 :: Switch _5                             = Key 0x0035-_6 :: Key+_6 :: Switch _6                             = Key 0x0036-_7 :: Key+_7 :: Switch _7                             = Key 0x0037-_8 :: Key+_8 :: Switch _8                             = Key 0x0038-_9 :: Key+_9 :: Switch _9                             = Key 0x0039-_Colon :: Key+_Colon :: Switch _Colon                         = Key 0x003a-_Semicolon :: Key+_Semicolon :: Switch _Semicolon                     = Key 0x003b-_Less :: Key+_Less :: Switch _Less                          = Key 0x003c-_Equal :: Key+_Equal :: Switch _Equal                         = Key 0x003d-_Greater :: Key+_Greater :: Switch _Greater                       = Key 0x003e-_Question :: Key+_Question :: Switch _Question                      = Key 0x003f-_At :: Key+_At :: Switch _At                            = Key 0x0040-_A :: Key+_A :: Switch _A                             = Key 0x0041-_B :: Key+_B :: Switch _B                             = Key 0x0042-_C :: Key+_C :: Switch _C                             = Key 0x0043-_D :: Key+_D :: Switch _D                             = Key 0x0044-_E :: Key+_E :: Switch _E                             = Key 0x0045-_F :: Key+_F :: Switch _F                             = Key 0x0046-_G :: Key+_G :: Switch _G                             = Key 0x0047-_H :: Key+_H :: Switch _H                             = Key 0x0048-_I :: Key+_I :: Switch _I                             = Key 0x0049-_J :: Key+_J :: Switch _J                             = Key 0x004a-_K :: Key+_K :: Switch _K                             = Key 0x004b-_L :: Key+_L :: Switch _L                             = Key 0x004c-_M :: Key+_M :: Switch _M                             = Key 0x004d-_N :: Key+_N :: Switch _N                             = Key 0x004e-_O :: Key+_O :: Switch _O                             = Key 0x004f-_P :: Key+_P :: Switch _P                             = Key 0x0050-_Q :: Key+_Q :: Switch _Q                             = Key 0x0051-_R :: Key+_R :: Switch _R                             = Key 0x0052-_S :: Key+_S :: Switch _S                             = Key 0x0053-_T :: Key+_T :: Switch _T                             = Key 0x0054-_U :: Key+_U :: Switch _U                             = Key 0x0055-_V :: Key+_V :: Switch _V                             = Key 0x0056-_W :: Key+_W :: Switch _W                             = Key 0x0057-_X :: Key+_X :: Switch _X                             = Key 0x0058-_Y :: Key+_Y :: Switch _Y                             = Key 0x0059-_Z :: Key+_Z :: Switch _Z                             = Key 0x005a-_BracketLeft :: Key+_BracketLeft :: Switch _BracketLeft                   = Key 0x005b-_Backslash :: Key+_Backslash :: Switch _Backslash                     = Key 0x005c-_BracketRight :: Key+_BracketRight :: Switch _BracketRight                  = Key 0x005d-_Circumflex :: Key+_Circumflex :: Switch _Circumflex                    = Key 0x005e-_Underscore :: Key+_Underscore :: Switch _Underscore                    = Key 0x005f-_Grave :: Key+_Grave :: Switch _Grave                         = Key 0x0060-_BraceLeft :: Key+_BraceLeft :: Switch _BraceLeft                     = Key 0x007b-_Bar :: Key+_Bar :: Switch _Bar                           = Key 0x007c-_BraceRight :: Key+_BraceRight :: Switch _BraceRight                    = Key 0x007d-_Tilde :: Key+_Tilde :: Switch _Tilde                         = Key 0x007e
generate_keys.py view
@@ -53,7 +53,7 @@             names = ['_' + name for name in names]             # Gather all the aliases into the same signature, so Haddock             # displays them on one line-            print(', '.join(names), ':: Key')+            print(', '.join(names), ':: Switch')             for name in names:                 print(name.ljust(30), '= Key', code) 
robot.cabal view
@@ -1,5 +1,5 @@ Name:                robot-Version:             1.3.0.1+Version:             1.4 Synopsis:            Simulate keyboard and mouse events Homepage:            https://github.com/lfairy/robot License:             OtherLicense@@ -32,7 +32,7 @@      Build-Depends:    base == 4.*                     , containers-                    , exceptions == 0.6.*+                    , exceptions >= 0.6                     , transformers                     , xhb