Jump to content

Recommended Posts

Posted
; 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

Posted

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

 

Posted
; 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

 

Posted
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!

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...