Jump to content

wait for keypress


Recommended Posts

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.

Link to comment
Share on other sites

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
;
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...