Jump to content

Help with a One-Button Hotkey loop


 Share

Recommended Posts

So here's the thing, I made this Script for a game to be a simple macro but the only thing wrong with it is I want it just to be one button instead of having to press the "HOME" key to start and the "END" key to stop. I wanted it to be "NUMPADDOT" but can't seem to tweak it the way I want. Any suggestions?

;##################### Options #######################
Opt("SendKeyDownDelay", 0)
Opt("SendKeyDelay", 0)
;##################### Hotkeys #######################
HotkeySet("{HOME}", "_Start")
HotkeySet("{END}", "_Stop")
;##################### Variables #######################
$stop = 0
;##################### Main Loop #######################
While 1
$stop = 0
Sleep(5)
WEnd
;##################### Functions #######################
Func _Start()
Do
Send("d4")
Sleep(200)
Until $stop = 1
EndFunc


Func _Stop()
$stop = 1
EndFunc
Link to comment
Share on other sites

;##################### Options #######################
Opt("SendKeyDownDelay", 0)
Opt("SendKeyDelay", 0)
;##################### Hotkeys #######################
HotKeySet("{NUMPADDOT}", "_StartUndStop")
HotKeySet("{ESC}", "_Quit")
;##################### Variables #######################
Local $fStart = False
;##################### Main Loop #######################
While 1
    Sleep(20)
WEnd
;##################### Functions #######################
Func _StartUndStop()
    $fStart = Not $fStart
    
    While $fStart
        Send("d4")
        Sleep(200)
    WEnd
EndFunc   ;==>_Start

Func _Quit()
    Exit
EndFunc

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...