motionman95 Posted March 30, 2009 Share Posted March 30, 2009 Is there a function in AutoIt to detect mouse movement? I want to be able to detect if the mouse has been idle for more than 5 minutes, and if so, hide my application. On the return of mouse movement, I want my app to reappear. Thanks in advance, motionman95 Link to comment Share on other sites More sharing options...
zutto Posted March 30, 2009 Share Posted March 30, 2009 Is there a function in AutoIt to detect mouse movement? I want to be able to detect if the mouse has been idle for more than 5 minutes, and if so, hide my application. On the return of mouse movement, I want my app to reappear. Thanks in advance, motionman95 $s = mousegetpos() do $x = 0 if $s = Mousegetpos() then ;??? else ;??? $x = 0 endif $x = $x + 1 sleep(1000) untill $x = 300000 Link to comment Share on other sites More sharing options...
motionman95 Posted March 30, 2009 Author Share Posted March 30, 2009 Will that code work even if the PC is locked? Link to comment Share on other sites More sharing options...
motionman95 Posted March 30, 2009 Author Share Posted March 30, 2009 Bump Link to comment Share on other sites More sharing options...
youknowwho4eva Posted March 30, 2009 Share Posted March 30, 2009 Don't bump less than 24 hours after your last post please Why not try and see? Giggity Link to comment Share on other sites More sharing options...
Bert Posted March 30, 2009 Share Posted March 30, 2009 If your PC is locked, no it won't. You would need to run it as a service to detect it. Seeing how you would only need to see it while your PC is unlocked, it should not be a issue. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
KaFu Posted March 30, 2009 Share Posted March 30, 2009 See __Timer_IdleChecker() example in my signature. _Timer_GetIdleTime() checks if Mouse OR Keyboard input happend. If you want to deactivate the WinActive check replace if @AutoItPID <> WinGetProcess(_WinAPI_GetAncestor(WinGetHandle("[ACTIVE]"), $GA_ROOTOWNER)) then; none of the programs windows are active $bIdle = true Else if _Timer_GetIdleTime() > $iIdle_Time Then; program considered idle after x ms of inactivity $bIdle = True Else $bIdle = False endif endif with if _Timer_GetIdleTime() > $iIdle_Time Then; program considered idle after x ms of inactivity $bIdle = True Else $bIdle = False endif OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
herewasplato Posted March 31, 2009 Share Posted March 31, 2009 (edited) If the computer is locked - but logged onto - then then timer and window minimize function will work. The mouse movement is not detected by the script when the computer is locked - at least not in the virtual machine that I tested this on:$begin = TimerInit() While 1 $moved = "no" $pos1 = MouseGetPos() Sleep(50) $pos2 = MouseGetPos() If $pos1[0] <> $pos2[0] Then $moved = "yes" If $pos1[1] <> $pos2[1] Then $moved = "yes" If $moved = "yes" Then WinActivate("C:\Doc") $begin = TimerInit() EndIf If TimerDiff($begin) > 300000 And $moved = "no" Then WinSetState("C:\Doc", "", @SW_MINIMIZE) $begin = TimerInit() EndIf WEnd Edited March 31, 2009 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now