Jump to content

hotkey with single function


Go to solution Solved by JohnOne,

Recommended Posts

;#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
Link to comment
Share on other sites

  • Solution

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.

Link to comment
Share on other sites

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
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...