Advertisement
Guest User

Untitled

a guest
Jul 16th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.65 KB | None | 0 0
  1. #include <winapi.au3>
  2. #include <WindowsConstants.au3>
  3.  
  4. ; Initializing
  5. Global $botEnabled = 0
  6. TrayTip("Information", "Press F2 to run/pause. F3 to exit program", 1, 1)
  7.  
  8. ; This function changes and returns the status of the program (enabled or disabled)
  9. Func bot()
  10.    $botEnabled = BitXOR($botEnabled, 1)
  11.  EndFunc
  12. HotKeySet("{F2}", "bot")
  13. HotKeySet("{F3}", "ExitProgram")
  14.  
  15. ; Program process run
  16. While True
  17.         ; If program is enabled
  18.    If $botEnabled Then
  19.           $hwnd = WinActive('')
  20.           If $hwnd <> 0 Then
  21.                  _SendKey($hwnd, 0x20) ; 0x20 for Space
  22.                  Sleep(500)
  23.           EndIf ; end of $hdwnd <> 0
  24.    EndIf ; end of If $botEnabled
  25. WEnd
  26.  
  27. Func _SendKey($hwnd, $skey)
  28.    ;DllCall("user32.dll", "int", "SetFocus", "hwnd", $hwnd)
  29.    ;$skey = 0x20 ; 0x20 is the Space button
  30.  
  31.    $ret = DllCall("user32.dll", "int", "MapVirtualKey", "int", $skey, "int", 0)
  32.    $lparam = BitShift($ret[0], -16)
  33.    $lparam = BitOr($lparam, 1)
  34.    $lUpparam = BitOR($lparam, 0xC0000000)
  35.  
  36.    TrayTip("Information", "$WM_KEYDOWN = " & $WM_KEYDOWN & " $WM_KEYUP = " & $WM_KEYUP & " Hex($lparam) = 0x"  & Hex($lparam), 1, 1)
  37.    Sleep(5000)
  38.  
  39.    DllCall("user32.dll", "int", "SendMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", $skey, "long", $lparam) ; 0x00390001
  40.    TrayTip("Information", "Space down", 1, 1)
  41.    Sleep(500)
  42.    DllCall("user32.dll", "int", "SendMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", $skey, "long", $lUpparam)
  43.    TrayTip("Information", "Space up", 1, 1)
  44. EndFunc
  45.  
  46. ; Quits the program
  47. Func ExitProgram()
  48.    TrayTip("Information", "Exiting program...", 1, 1)
  49.    Sleep(1500)
  50.    Exit
  51. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement