Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode, Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- SetBatchLines, -1
- #MaxThreadsPerHotkey 2
- CoordMode, Pixel, Screen ; initialization can go before main function of the script
- global toggle := 0 ; assigning variables
- global sleepCheck := 250
- Hotkey, F1, ToggleScript ; assigning hotkeys to functions
- Hotkey, F3, Exit
- ToggleScript(){ ; toggle function
- if(toggle = 0){
- toggle := 1
- }
- else{
- toggle := 0
- }
- }
- MainScript() ; main script function trigger
- MainScript(){
- Loop,{
- if(toggle != 0){
- ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, 95 1.png ; first image check with catch statement
- if(!ErrorLevel){ ; if no error is found
- Send, {u up}
- Send, {k}
- sleep, 500
- }
- else{
- Send, {u down}
- sleep, 2000
- Send, {u up}
- }
- ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, 95 2.png ; second image check with catch statement
- if(!ErrorLevel){ ; if no error is found
- Send, {u up}
- Send, {k}
- Sleep, 500
- }
- else{
- Send, {u down}
- sleep, 2000
- Send, {u up}
- }
- }
- Sleep, %sleepCheck%
- }
- }
- Exit(){
- ExitApp
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement