xerxes2985 Posted August 27, 2019 Posted August 27, 2019 ; Script Start #include <WinAPISys.au3> $title = "Internet Explorer" $minutes = 15 Opt("WinTitleMatchMode", 2) ;2 = Match any substring in the title While 1 ; If the system is idle for more than X minutes then: If _WinAPI_GetIdleTime() >= $minutes * 60 * 1000 AND WinExists($title) Then WinClose($title) ; Exit EndIf ; After one loop is complete, send a keystroke, and sleep for 5 seconds before starting the loop again: Send("{UP}") Sleep(5000) WEnd Hey all, I found this script and added the option line, so not to have to exact match on the title. The script works, however, unless there is physical user interaction on the mouse or keyboard, the loop closes the program once after 15 minutes, then continually closes the program every 5 seconds. I added the Send("{UP}") to send a keystroke, and have placed it in the While loop, as well, I tried outside of the While loop, but it has no effect. Could someone guide me on if there is a way to reset the idle time, or what I can do to send a keystroke or something to basically create activity, therefore resetting the idle time? I'm using this program on a W10 kiosk using embedded shell launcher, so I don't need to restart the program, it does it on its own. Thanks! Jesse
KaFu Posted August 27, 2019 Posted August 27, 2019 I use this simple program: TraySetToolTip("Mousemove - Exit = WIN + ESC") HotKeySet("#{ESC}", "_Exit") ; WIN + ESC $i = 1 While Sleep(60 * 1000) $aPos = MouseGetPos() If $i = 1 Then $i = 0 MouseMove($aPos[0], $aPos[1] + 1, 0) Else MouseMove($aPos[0], $aPos[1] - 1, 0) $i = 1 EndIf WEnd Func _Exit() ConsoleWrite("Exit" & @CRLF) Exit EndFunc ;==>_Exit OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
xerxes2985 Posted August 27, 2019 Author Posted August 27, 2019 That does well to move the mouse when the system is idle, but would I just take that and place it after my while loop? Thanks
KaFu Posted August 27, 2019 Posted August 27, 2019 ; Script Start #include <WinAPISys.au3> $title = "Internet Explorer" $minutes = 15 Opt("WinTitleMatchMode", 2) ;2 = Match any substring in the title Local $aPos, $b_Switch While 1 ; If the system is idle for more than X minutes then: If _WinAPI_GetIdleTime() >= $minutes * 60 * 1000 AND WinExists($title) Then WinClose($title) ; Exit EndIf ; After one loop is complete, send a keystroke, and sleep for 5 seconds before starting the loop again: $aPos = MouseGetPos() If $b_Switch = True Then MouseMove($aPos[0], $aPos[1] + 1, 0) Else MouseMove($aPos[0], $aPos[1] - 1, 0) EndIf $b_Switch = not $b_Switch Sleep(5000) WEnd OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
xerxes2985 Posted August 27, 2019 Author Posted August 27, 2019 That still moves the mouse cursor, and doesn't let the idle time ever get to the 15 minutes.
xerxes2985 Posted August 27, 2019 Author Posted August 27, 2019 13 minutes ago, xerxes2985 said: That still moves the mouse cursor, and doesn't let the idle time ever get to the 15 minutes. Disregard, I removed the ; Exit EndIf and its working fine. Thanks for your help!
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