Advertisement
EzFlow997

Example Script 1

Jan 8th, 2024 (edited)
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Autohotkey 1.42 KB | Source Code | 0 0
  1. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. ; #Warn  ; Enable warnings to assist with detecting common errors.
  3. SendMode, Input  ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  5. SetBatchLines, -1
  6. #MaxThreadsPerHotkey 2
  7.  
  8. CoordMode, Pixel, Screen ; initialization can go before main function of the script
  9.  
  10. global toggle := 0 ; assigning variables
  11. global sleepCheck := 250
  12.  
  13. Hotkey, F1, ToggleScript ; assigning hotkeys to functions
  14. Hotkey, F3, Exit
  15.  
  16. ToggleScript(){      ; toggle function
  17.     if(toggle = 0){
  18.         toggle := 1
  19.     }
  20.     else{
  21.         toggle := 0
  22.     }
  23. }
  24.  
  25. MainScript()   ; main script function trigger
  26. MainScript(){
  27.     Loop,{
  28.         if(toggle != 0){
  29.             ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, 95 1.png     ; first image check with catch statement
  30.             if(!ErrorLevel){   ;  if no error is found
  31.                 Send, {u up}
  32.                 Send, {k}
  33.                 sleep, 500
  34.             }
  35.             else{
  36.                 Send, {u down}
  37.                 sleep, 2000
  38.                 Send, {u up}
  39.             }
  40.             ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, 95 2.png   ; second image check with catch statement
  41.             if(!ErrorLevel){   ; if no error is found
  42.                 Send, {u up}
  43.                 Send, {k}
  44.                 Sleep, 500
  45.             }
  46.             else{
  47.                 Send, {u down}
  48.                 sleep, 2000
  49.                 Send, {u up}
  50.             }
  51.         }
  52.         Sleep, %sleepCheck%
  53.     }
  54. }
  55.  
  56. Exit(){
  57.     ExitApp
  58. }
Tags: ahk
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement