Jump to content
Sign in to follow this  
Phenom

wait for keypress

Recommended Posts

Phenom

How can I get my script to wait for the user to press the enter key?

Share this post


Link to post
Share on other sites
Tvern

Look at HotKeySet in the helpfile.

Share this post


Link to post
Share on other sites
Phenom

Yeah, I can do something like that using Hotkeys but I was wondering if there was another way.

Share this post


Link to post
Share on other sites
Tvern

There are loads of other ways. For example you could use _IsPressed, or capture the WM_KEYDOWN message, but Hotkeyset seems to do exactly what you asked for, so I see little reason to reïnvent the weel.

Share this post


Link to post
Share on other sites
sahsanu

Yeah, I can do something like that using Hotkeys but I was wondering if there was another way.

Take a look to _IsPressed function.

Edit: Sorry, I didn't see Tvern post

Edited by sahsanu

Share this post


Link to post
Share on other sites
Malkey

Like this example.

Press Enter to continue script to message box.

Notice, no "#Include <Misc.au3>" needed.

_WaitEnterKey()

MsgBox(0, "End of wait", " Enter key pressed")


; Modified from _IsPressed() from Misc.au3 UDF include file.
; Wait for "Enter" key to be pressed.
Func _WaitEnterKey()
    Local $a_R, $vDLL = DllOpen("user32.dll")
    Do
        Sleep(10)
        $a_R = DllCall($vDLL, "short", "GetAsyncKeyState", "int", '0x0D') ; "0D" - Enter key
    Until $a_R[0]
    DllClose($vDLL)
    Return 1
EndFunc ;==>_WaitEnterKey
;

Share this post


Link to post
Share on other sites
a440hz

Like this example.

Press Enter to continue script to message box.

Notice, no "#Include <Misc.au3>" needed.

_WaitEnterKey()

MsgBox(0, "End of wait", " Enter key pressed")


; Modified from _IsPressed() from Misc.au3 UDF include file.
; Wait for "Enter" key to be pressed.
Func _WaitEnterKey()
    Local $a_R, $vDLL = DllOpen("user32.dll")
    Do
        Sleep(10)
        $a_R = DllCall($vDLL, "short", "GetAsyncKeyState", "int", '0x0D') ; "0D" - Enter key
    Until $a_R[0]
    DllClose($vDLL)
    Return 1
EndFunc ;==>_WaitEnterKey
;

Nice. Any advantages to using this to as opposed to _IsPressed() other than not having to include Misc.au3? I'm specifically thinking about the best way to intercept '0x01' for mouse clicks


Are you experienced?

Share this post


Link to post
Share on other sites
Phenom

Nice. Any advantages to using this to as opposed to _IsPressed() other than not having to include Misc.au3? I'm specifically thinking about the best way to intercept '0x01' for mouse clicks

I don't notice a difference. Whatever window is active will still register that an Enter key was pressed. I would like the program to intercept the Enter key so that nothing gets accidentally selected. I'm also interested in a way to intercept mouse clicks so that things don't accidentally get selected. I want to specify points on the screen with the mouse, but clicking the mouse just causes the program to lose focus. What do you plan to do with intercepting mouse clicks, something similar?

Edited by Phenom

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.