Jump to content

executing macro when holding key down


kazie
 Share

Recommended Posts

I want to make a macro that spams up, down, up, down,... that's simple enough to make but i want it to only execute when i hold down a key.

lets say that key is w. if i hold down w, the macro will spam up, down until i let go of w.

Link to comment
Share on other sites

  • Moderators

Kazie, can you explain exactly what you're trying to do? Often times there are much easier ways than sending keys.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

#include <Misc.au3>

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

While 1
    If _IsPressed("10", $hDLL) Then
        ConsoleWrite("_IsPressed - Shift Key was pressed." & @CRLF)
        ; Wait until key is released.
        While _IsPressed("10", $hDLL)
            Sleep(250)
        WEnd
        ConsoleWrite("_IsPressed - Shift Key was released." & @CRLF)
    ElseIf _IsPressed("1B", $hDLL) Then
        MsgBox(0, "_IsPressed", "The Esc Key was pressed, therefore we will close the application.")
        ExitLoop
    EndIf
    Sleep(200)
WEnd

DllClose($hDLL)

This is directly from the help file and looks like you could easily insert and function into it to simply spam the keys you are after WHILE it is pressed... Look at the line with sleep(250)

Edited by Keltset

-K

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