Jump to content
Sign in to follow this  
kazie

executing macro when holding key down

Recommended Posts

kazie

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
JLogan3o13

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


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Keltset

#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

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  

×