Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <winapi.au3>
- #include <WindowsConstants.au3>
- ; Initializing
- Global $botEnabled = 0
- TrayTip("Information", "Press F2 to run/pause. F3 to exit program", 1, 1)
- ; This function changes and returns the status of the program (enabled or disabled)
- Func bot()
- $botEnabled = BitXOR($botEnabled, 1)
- EndFunc
- HotKeySet("{F2}", "bot")
- HotKeySet("{F3}", "ExitProgram")
- ; Program process run
- While True
- ; If program is enabled
- If $botEnabled Then
- $hwnd = WinActive('')
- If $hwnd <> 0 Then
- _SendKey($hwnd, 0x20) ; 0x20 for Space
- Sleep(500)
- EndIf ; end of $hdwnd <> 0
- EndIf ; end of If $botEnabled
- WEnd
- Func _SendKey($hwnd, $skey)
- ;DllCall("user32.dll", "int", "SetFocus", "hwnd", $hwnd)
- ;$skey = 0x20 ; 0x20 is the Space button
- $ret = DllCall("user32.dll", "int", "MapVirtualKey", "int", $skey, "int", 0)
- $lparam = BitShift($ret[0], -16)
- $lparam = BitOr($lparam, 1)
- $lUpparam = BitOR($lparam, 0xC0000000)
- TrayTip("Information", "$WM_KEYDOWN = " & $WM_KEYDOWN & " $WM_KEYUP = " & $WM_KEYUP & " Hex($lparam) = 0x" & Hex($lparam), 1, 1)
- Sleep(5000)
- DllCall("user32.dll", "int", "SendMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", $skey, "long", $lparam) ; 0x00390001
- TrayTip("Information", "Space down", 1, 1)
- Sleep(500)
- DllCall("user32.dll", "int", "SendMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", $skey, "long", $lUpparam)
- TrayTip("Information", "Space up", 1, 1)
- EndFunc
- ; Quits the program
- Func ExitProgram()
- TrayTip("Information", "Exiting program...", 1, 1)
- Sleep(1500)
- Exit
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement