Jump to content

Recommended Posts

Posted

_IsPressed detects given keypress but how to dedect anykey/mouse move? I want to close my window as soon as user presses any key/moves mouse.

edited

Posted

Thanks. Now close my app for mouse move I just would like to close for keypress too. At the moment only esc closes it.

edited

Posted (edited)

unfortunately all i can think of is going through all possible key combos and combining them with the "Or" operator, this way any key press would register.

This method is messy, but it would work. You could probably do it in steps or build a seperate function like keyIsPressed() that returns a boolean value.

I wonder if anyone else has a simpler option... ;)

Edited by Drifter
Posted (edited)

Here's somethig I've been fiddling with lately. You may find it useful. Keep in mind that I'm new to using DLLs and whatnot.

Link to the MSDN article: GetKeyboardState

Global Const $byteArray = DllStructCreate("BYTE lpKeyState[256]")
Global Const $lpKeyState = DllStructGetPtr($byteArray)

DllCall("User32.dll", "bool", "GetKeyboardState", "ptr", $lpKeyState)

Global Const $KeyboardState = DllStructGetData($byteArray, "lpKeyState")

Global $j = 1

For $i = 3 To StringLen($KeyboardState) Step 4
    ConsoleWrite($j & " " & StringMid($KeyboardState, $i, 4) & @LF)
    $j += 1
Next
Edited by jaberwocky6669
Posted

unfortunately all i can think of is going through all possible key combos and combining them with the "Or" operator, this way any key press would register.

This method is messy, but it would work. You could probably do it in steps or build a seperate function like keyIsPressed() that returns a boolean value.

I wonder if anyone else has a simpler option... ;)

this has been addressed before... search for "any key pressed" i think will find it

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
×
×
  • Create New...