Jump to content
Sign in to follow this  

executing macro when holding key down

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.

Share this post

Link to post
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)
        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.")


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


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