Sign in to follow this  
Followers 0
tsincaat

while a key is down?

5 posts in this topic

#1 ·  Posted (edited)

I'm wondering how I can set up a "while" for when a key is being held down? If not for a while, then something that would allow me to execute some kind of loop while a key is being held down. Right now I know how to send keys, hold down keys with autoit, and set hotkeys to run a function, but not how to do this.

Thanks!

Edited by tsincaat

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

For simplistic needs, a function:

#include <Misc.au3>

While 1
    _IsDown("09", "_Do")
    Sleep(500)
WEnd

Func _IsDown($ioKey, $ioFunc)
    While _IsPressed($ioKey)
        Call($ioFunc)
        Sleep(10)
    WEnd
EndFunc

Func _Do()
    ConsoleWrite("Tab is held!" & @CRLF)
EndFunc
Edited by JamesBrooks

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I'm wondering how I can set up a "while" for when a key is being held down? If not for a while, then something that would allow me to execute some kind of loop while a key is being held down. Right now I know how to send keys, hold down keys with autoit, and set hotkeys to run a function, but not how to do this.

Thanks!

_IsPressed function:

#include <Misc.au3>
While 1
    If _IsPressed("41") Then
        TrayTip("TEST","You hold down key A",1)
    Else
        TrayTip("","",1)
    EndIf
    Sleep(10)
WEnd

EDIT: a little too late :P

Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites

You guys are SO helpful!

Thank you, all 3 of you :P

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