Created
January 22, 2020 00:54
-
-
Save andrewsuzuki/76235480227579bf277afc89c0dc1d06 to your computer and use it in GitHub Desktop.
AutoIt script for activating (focusing) a window automatically after an idle timeout (no mouse/keyboard interaction)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Activate window after idle timeout | |
; Script for AutoIt (Windows) | |
; by Andrew Suzuki | |
#include <WinAPISys.au3> | |
$title = "YOUR WINDOW TITLE HERE" | |
$minutes = 2 ; every two minutes | |
$sleepTimeMillis = 5*1000 ; check every 5 seconds | |
; Match any substring in title | |
AutoItSetOption("WinTitleMatchMode", 2) | |
While 1 | |
; If the idle timer is more than $minutes... | |
If _WinAPI_GetIdleTime() >= $minutes * 60 * 1000 Then | |
; Attempt to activate window | |
If Not (WinActivate($title)) Then | |
; Matching window not found | |
; Do what you want here (exec, msgbox error, etc) | |
EndIf | |
EndIf | |
; Sleep for $sleepTimeMillis before looping again | |
Sleep($sleepTimeMillis) | |
WEnd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment