Jump to content
Sign in to follow this  
E1M1

How to dedect activity?

Recommended Posts

E1M1

_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

Share this post


Link to post
Share on other sites
E1M1

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

Share this post


Link to post
Share on other sites
Drifter

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

Share this post


Link to post
Share on other sites
jaberwacky

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

Share this post


Link to post
Share on other sites
seandisanti

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

Share this post


Link to post
Share on other sites
E1M1

none of solutions above worked, but help file helped me again, I modified _WinAPI_SetWindowsHookEx example.


edited

Share this post


Link to post
Share on other sites
PsaltyDS

Did you try _Timer_GetIdleTime()? The time resets with any activity on mouse or keyboard.

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×