#Region ### AutoIt Wrapper ### #AutoIt3Wrapper_Res_Fileversion=1.0.0.1 #AutoIt3Wrapper_Res_FileVersion_AutoIncrement=y ; Don't show the tray icon... causes issues if you click on it AutoItSetOption("TrayIconHide", 1) #EndRegion ### AutoIt Wrapper ### #Region ### Global Variables ### Global $x ; Mouse X position Global $y ; Mouse Y position Global $normalMode = False ; Toggle for text editing mode Global Const $log = @AppDataCommonDir & "\KeyboardMouse.log" Global Const $smallMouseIterator = 3 ; Movement of a small mouse move Global Const $mouseIterator = 30 ; Movement of a normal mouse move Global Const $bigMouseIterator = 100 ; Movement of a large mouse move #EndRegion ### Global Variables ### init() main() Func init() ; Toggle Execution Hotkey (Should never be removed) HotKeySet("!{F8}", "ToggleHotKeys") ; Exit (Should never be removed) HotKeySet("!{F9}", "Close") HotKeySetup() EndFunc Func main() ; just keep sleeping, just keep sleeping, ba ba ba ba bum While True sleep(100) WEnd EndFunc Func Close() ; Record that we're closing Debug("Closing") Exit EndFunc #Region ### HotKey Management ### Func HotKeySetup() ; Move Mouse ; Small HotKeySet("^+{RIGHT}", "smallMoveMouseRight") HotKeySet("^+{LEFT}", "smallMoveMouseLeft") HotKeySet("^+{DOWN}", "smallMoveMouseDown") HotKeySet("^+{UP}", "smallMoveMouseUp") ; Normal HotKeySet("{RIGHT}", "MoveMouseRight") HotKeySet("{LEFT}", "MoveMouseLeft") HotKeySet("{DOWN}", "MoveMouseDown") HotKeySet("{UP}", "MoveMouseUp") ; Big HotKeySet("^{RIGHT}", "BigMoveMouseRight") HotKeySet("^{LEFT}", "BigMoveMouseLeft") HotKeySet("^{DOWN}", "BigMoveMouseDown") HotKeySet("^{UP}", "BigMoveMouseUp") ; Click HotKeySet("^{SPACE}", "Click") HotKeySet("^+{SPACE}", "RightClick") EndFunc Func HotKeyRemovals() ; Copy and Pase HotKeySetup, use Find & Replace with below RegExp to get HotKeyRemovals :) ; (HotKeySet\(".*\"), \".*\"\) ; $1\) ; Move Mouse ; Small HotKeySet("^+{RIGHT}") HotKeySet("^+{LEFT}") HotKeySet("^+{DOWN}") HotKeySet("^+{UP}") ; Normal HotKeySet("{RIGHT}") HotKeySet("{LEFT}") HotKeySet("{DOWN}") HotKeySet("{UP}") ; Big HotKeySet("^{RIGHT}") HotKeySet("^{LEFT}") HotKeySet("^{DOWN}") HotKeySet("^{UP}") ; Click HotKeySet("^{SPACE}") HotKeySet("^+{SPACE}") EndFunc Func ToggleHotKeys() $normalMode = Not $normalMode Debug("Normal mode: " & $normalMode) if $normalMode Then Debug("Removing HotKeys") HotKeyRemovals() While $normalMode Sleep(100) WEnd Debug("Adding HotKeys Back") HotKeySetup() EndIf EndFunc #EndRegion ### HotKey Management ### #Region ### Mouse Movement ### Func UpdateMousePos() $x = MouseGetPos(0) $y = MouseGetPos(1) EndFunc Func MoveMouseDown() UpdateMousePos() MouseMove($x, $y + $mouseIterator) EndFunc Func MoveMouseUp() UpdateMousePos() MouseMove($x, $y - $mouseIterator) EndFunc Func MoveMouseRight() UpdateMousePos() MouseMove($x + $mouseIterator, $y) EndFunc Func MoveMouseLeft() UpdateMousePos() MouseMove($x - $mouseIterator, $y) EndFunc Func BigMoveMouseDown() UpdateMousePos() MouseMove($x, $y + $bigMouseIterator) EndFunc Func BigMoveMouseUp() UpdateMousePos() MouseMove($x, $y - $bigMouseIterator) EndFunc Func BigMoveMouseRight() UpdateMousePos() MouseMove($x + $bigMouseIterator, $y) EndFunc Func BigMoveMouseLeft() UpdateMousePos() MouseMove($x - $bigMouseIterator, $y) EndFunc Func smallMoveMouseDown() UpdateMousePos() MouseMove($x, $y + $smallMouseIterator) EndFunc Func smallMoveMouseUp() UpdateMousePos() MouseMove($x, $y - $smallMouseIterator) EndFunc Func smallMoveMouseRight() UpdateMousePos() MouseMove($x + $smallMouseIterator, $y) EndFunc Func smallMoveMouseLeft() UpdateMousePos() MouseMove($x - $smallMouseIterator, $y) EndFunc #EndRegion ### Mouse Movement ### #Region ### Clicking ### Func Click() UpdateMousePos() Send("{CTRLUP}") MouseClick("left", $x, $y) EndFunc Func RightClick() UpdateMousePos() Send("{CTRLUP}") MouseClick("right", $x, $y) EndFunc #EndRegion ### Clicking ### #Region ### Debugging ### Func Debug($Msg, $prefix = "+") ; If the script is compiled If @Compiled Then ; Write the the log, with the date, and ignore the prefix FileWrite($log, @MON & "/" & @MDAY & "/" & @YEAR & " - " & $Msg & @CRLF) Else ; Not compiled, probably through SciTE or command line, just write to the console ConsoleWrite($prefix & " " & $Msg & @CRLF) EndIf EndFunc ; Unused so far Func ErrMsg($Msg, $error ="") ; If there is not an error number If $error = "" Then Debug("Error: " & $Msg, "! ") Else Debug("Error: " & $error & " - " & $Msg, "!") EndIf EndFunc #EndRegion ### Debugging ###