Jump to content
Sign in to follow this  
Jujo

While key is pressed

Recommended Posts

Jujo

Hi again,

I need help for my program.

I want to have function called on key press (e.g. Left arrow), but to exit function and call another one when that key is released.

I now use HotKeySet, but I can't use it with key release:

HotKeySet("{LEFT}", "left")
HotKeySet("{RIGHT}", "right")
HotKeySet("{UP}", "up")
HotKeySet("{DOWN}", "down")
HotKeySet("{SPACE}", "wait")

I want that while {LEFT} is pressed, the left() function is called, and when {LEFT} is released, up() is called back.

Thanks ^_^

Share this post


Link to post
Share on other sites
Valuater

This is a working piece of code, just needs the include ( see help)

If _IsPressed("01", $hUser32_Dll) Then
        ;Waiting untill the button is released
        While _IsPressed("01", $hUser32_Dll)
            Sleep(10)
        WEnd

change the "01" to the key number you want

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
Jujo

Thanks, hope it works ^_^

Share this post


Link to post
Share on other sites
Jujo

I tried this, but I get error, I think that I need to include a DLL, but dont know where and which...

ERROR:

If _IsPressed("{LEFT}", $hUser32_Dll) Then

If _IsPressed("{LEFT}", ^ ERROR

EDIT: I looked help and included the misc.aue3 file like in help example, but still the same error

EDIT2: I changed {LEFT} to 25, like the help says. Still error. Error says "Variable used without beign declared". It means $hUser32_DLL variable

Edited by Jujo

Share this post


Link to post
Share on other sites
Jujo

Never mind, it works perfectly now ^_^

Thanks once again ;)

Share this post


Link to post
Share on other sites
Elettrone

Share it pls, how did you get it working.

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  

×