{-# LANGUAGE TypeApplications #-}
module AutoGUI.Mouse
( MouseButton(..)
, moveTo
, moveToDuration
, moveRel
, moveRelDuration
, click
, leftClick
, doubleClick
, tripleClick
, rightClick
, middleClick
, moveAndClick
, drag
, dragDuration
, dragTo
, dragToDuration
, dragRel
, dragRelDuration
, scroll
, mouseDown
, mouseUp
)
where
import AutoGUI.Call
import CPython.Simple
import CPython.Simple.Instances
import Data.Text
data MouseButton
= LeftMouseButton
| RightMouseButton
| MiddleMouseButton
instance ToPy MouseButton where
toPy :: MouseButton -> IO SomeObject
toPy MouseButton
LeftMouseButton = Text -> IO SomeObject
forall a. ToPy a => a -> IO SomeObject
toPy @Text Text
"left"
toPy MouseButton
RightMouseButton = Text -> IO SomeObject
forall a. ToPy a => a -> IO SomeObject
toPy @Text Text
"right"
toPy MouseButton
MiddleMouseButton = Text -> IO SomeObject
forall a. ToPy a => a -> IO SomeObject
toPy @Text Text
"middle"
moveTo :: Integer -> Integer -> IO ()
moveTo :: Integer -> Integer -> IO ()
moveTo Integer
x Integer
y = Text -> [Arg] -> [(Text, Arg)] -> IO ()
forall a. FromPy a => Text -> [Arg] -> [(Text, Arg)] -> IO a
pyautogui Text
"moveTo" [Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
x, Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
y] []
moveToDuration :: Integer -> Integer -> Double -> IO ()
moveToDuration :: Integer -> Integer -> Double -> IO ()
moveToDuration Integer
x Integer
y Double
duration =
Text -> [Arg] -> [(Text, Arg)] -> IO ()
forall a. FromPy a => Text -> [Arg] -> [(Text, Arg)] -> IO a
pyautogui Text
"moveTo" [Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
x, Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
y] [(Text
"duration", Double -> Arg
forall a. ToPy a => a -> Arg
arg Double
duration)]
moveRel :: Integer -> Integer -> IO ()
moveRel :: Integer -> Integer -> IO ()
moveRel Integer
xOffset Integer
yOffset =
Text -> [Arg] -> [(Text, Arg)] -> IO ()
forall a. FromPy a => Text -> [Arg] -> [(Text, Arg)] -> IO a
pyautogui Text
"moveRel" [Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
xOffset, Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
yOffset] []
moveRelDuration :: Integer -> Integer -> Double -> IO ()
moveRelDuration :: Integer -> Integer -> Double -> IO ()
moveRelDuration Integer
xOffset Integer
yOffset Double
duration =
Text -> [Arg] -> [(Text, Arg)] -> IO ()
forall a. FromPy a => Text -> [Arg] -> [(Text, Arg)] -> IO a
pyautogui Text
"moveRel" [Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
xOffset, Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
yOffset, Double -> Arg
forall a. ToPy a => a -> Arg
arg Double
duration] []
click :: MouseButton -> IO ()
click :: MouseButton -> IO ()
click MouseButton
button = Text -> [Arg] -> [(Text, Arg)] -> IO ()
forall a. FromPy a => Text -> [Arg] -> [(Text, Arg)] -> IO a
pyautogui Text
"click" [] [(Text
"button", MouseButton -> Arg
forall a. ToPy a => a -> Arg
arg MouseButton
button)]
doubleClick :: IO ()
doubleClick :: IO ()
doubleClick = Text -> [Arg] -> [(Text, Arg)] -> IO ()
forall a. FromPy a => Text -> [Arg] -> [(Text, Arg)] -> IO a
pyautogui Text
"doubleClick" [] []
tripleClick :: IO ()
tripleClick :: IO ()
tripleClick = Text -> [Arg] -> [(Text, Arg)] -> IO ()
forall a. FromPy a => Text -> [Arg] -> [(Text, Arg)] -> IO a
pyautogui Text
"tripleClick" [] []
leftClick :: IO ()
leftClick :: IO ()
leftClick = MouseButton -> IO ()
click MouseButton
LeftMouseButton
rightClick :: IO ()
rightClick :: IO ()
rightClick = MouseButton -> IO ()
click MouseButton
RightMouseButton
middleClick :: IO ()
middleClick :: IO ()
middleClick = MouseButton -> IO ()
click MouseButton
MiddleMouseButton
moveAndClick :: Integer -> Integer -> IO ()
moveAndClick :: Integer -> Integer -> IO ()
moveAndClick Integer
x Integer
y = Integer -> Integer -> IO ()
moveTo Integer
x Integer
y IO () -> IO () -> IO ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> MouseButton -> IO ()
click MouseButton
LeftMouseButton
drag :: Integer -> Integer -> IO ()
drag :: Integer -> Integer -> IO ()
drag Integer
x Integer
y = Text -> [Arg] -> [(Text, Arg)] -> IO ()
forall a. FromPy a => Text -> [Arg] -> [(Text, Arg)] -> IO a
pyautogui Text
"drag" [Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
x, Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
y] []
dragDuration :: Integer -> Integer -> Double -> IO ()
dragDuration :: Integer -> Integer -> Double -> IO ()
dragDuration Integer
x Integer
y Double
duration = Text -> [Arg] -> [(Text, Arg)] -> IO ()
forall a. FromPy a => Text -> [Arg] -> [(Text, Arg)] -> IO a
pyautogui Text
"drag" [Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
x, Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
y, Double -> Arg
forall a. ToPy a => a -> Arg
arg Double
duration] []
dragTo :: Integer -> Integer -> IO ()
dragTo :: Integer -> Integer -> IO ()
dragTo Integer
x Integer
y = Text -> [Arg] -> [(Text, Arg)] -> IO ()
forall a. FromPy a => Text -> [Arg] -> [(Text, Arg)] -> IO a
pyautogui Text
"dragTo" [Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
x, Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
y] []
dragToDuration :: Integer -> Integer -> Double -> IO ()
dragToDuration :: Integer -> Integer -> Double -> IO ()
dragToDuration Integer
x Integer
y Double
duration = Text -> [Arg] -> [(Text, Arg)] -> IO ()
forall a. FromPy a => Text -> [Arg] -> [(Text, Arg)] -> IO a
pyautogui Text
"dragTo" [Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
x, Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
y, Double -> Arg
forall a. ToPy a => a -> Arg
arg Double
duration] []
dragRel :: Integer -> Integer -> IO ()
dragRel :: Integer -> Integer -> IO ()
dragRel Integer
xOffset Integer
yOffset = Text -> [Arg] -> [(Text, Arg)] -> IO ()
forall a. FromPy a => Text -> [Arg] -> [(Text, Arg)] -> IO a
pyautogui Text
"dragRel" [Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
xOffset, Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
yOffset] []
dragRelDuration :: Integer -> Integer -> Double -> IO ()
dragRelDuration :: Integer -> Integer -> Double -> IO ()
dragRelDuration Integer
xOffset Integer
yOffset Double
duration =
Text -> [Arg] -> [(Text, Arg)] -> IO ()
forall a. FromPy a => Text -> [Arg] -> [(Text, Arg)] -> IO a
pyautogui Text
"dragRel" [Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
xOffset, Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
yOffset, Double -> Arg
forall a. ToPy a => a -> Arg
arg Double
duration] []
scroll :: Integer -> IO ()
scroll :: Integer -> IO ()
scroll Integer
amount = Text -> [Arg] -> [(Text, Arg)] -> IO ()
forall a. FromPy a => Text -> [Arg] -> [(Text, Arg)] -> IO a
pyautogui Text
"scroll" [Integer -> Arg
forall a. ToPy a => a -> Arg
arg Integer
amount] []
mouseDown :: IO ()
mouseDown :: IO ()
mouseDown = Text -> [Arg] -> [(Text, Arg)] -> IO ()
forall a. FromPy a => Text -> [Arg] -> [(Text, Arg)] -> IO a
pyautogui Text
"mouseDown" [] []
mouseUp :: IO ()
mouseUp :: IO ()
mouseUp = Text -> [Arg] -> [(Text, Arg)] -> IO ()
forall a. FromPy a => Text -> [Arg] -> [(Text, Arg)] -> IO a
pyautogui Text
"mouseUp" [] []
mouseButtonDown :: MouseButton -> IO ()
mouseButtonDown :: MouseButton -> IO ()
mouseButtonDown MouseButton
button = Text -> [Arg] -> [(Text, Arg)] -> IO ()
forall a. FromPy a => Text -> [Arg] -> [(Text, Arg)] -> IO a
pyautogui Text
"mouseDown" [] [(Text
"button", MouseButton -> Arg
forall a. ToPy a => a -> Arg
arg MouseButton
button)]
mouseButtonUp :: MouseButton -> IO ()
mouseButtonUp :: MouseButton -> IO ()
mouseButtonUp MouseButton
button = Text -> [Arg] -> [(Text, Arg)] -> IO ()
forall a. FromPy a => Text -> [Arg] -> [(Text, Arg)] -> IO a
pyautogui Text
"mouseUp" [] [(Text
"button", MouseButton -> Arg
forall a. ToPy a => a -> Arg
arg MouseButton
button)]