Sign in to follow this  
Followers 0
taurus

hotkey with single function

4 posts in this topic

#1 ·  Posted (edited)

;#work in progress.
;~ #RequireAdmin
Global $Macro = False

HotKeySet("{SPACE}", "SpaceMacro")


While 1
    Sleep(100)
WEnd

Func SpaceMacro()
    $Macro = Not $Macro
    While $Macro
        Send("{SPACE}")
        Sleep(250)
        ConsoleWrite("WORK")
    WEnd
    ConsoleWrite("TEST")
EndFunc

i am trying to make that hotkey (SPACE) to call the function and keep running while loop , and when space pressed again stop the loop. but it just runs it one time thats that. what am i doing wrong? 

I know the forum rules, no hacks , cheats. but this isnt hack. keyboard macro are allowed in games. this is exactly what itll be . keyboard macro to save my spacebar

Edited by taurus

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Simplest fix, use a different HotKey to the one you are using, because you're sending it too, which is consequently sending HotKey again.

Change {SPACE} for something else.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

This may be worth a look as well.

https://www.autoitscript.com/autoit3/docs/libfunctions/_IsPressed.htm

 

Seems  to work:

#include <Misc.au3>

Local $hDLL = DLLOpen("user32.dll")

While 1
    If _IsPressed("20", $hDLL) Then
        Send("{Space}")
        Sleep(100)
        ConsoleWrite("Active")
    EndIf
    Sleep(100)
    WEnd
Edited by ViciousXUSMC

Share this post


Link to post
Share on other sites

aha ok so just had to replace it . got it 

Share this post


Link to post
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
Sign in to follow this  
Followers 0