-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoClose.ahk
More file actions
38 lines (30 loc) · 1.09 KB
/
AutoClose.ahk
File metadata and controls
38 lines (30 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#Persistent
#SingleInstance Ignore
; Source: https://superuser.com/questions/1688840/auto-close-program-after-x-seconds-inactivity-in-that-program
SetTimer, close_inactive_Opera_window, 1000 ; 1 second timer
return
close_inactive_Opera_window:
If !WinActive("ahk_exe opera.exe")
time++ ; checks the number in the variable "time" and increases it by 1 every 1 second (in accordance with the timer period)
else
time := 0 ; reset
If (time = 300) ; 300 seconds
{
WinClose, ahk_exe opera.exe
time := 0 ; reset
}
return
#If MouseIsOver("ahk_exe opera.exe")
~WheelUp::
~WheelDown::
time := 0 ; reset
return
#If
MouseIsOver(WinTitle){
MouseGetPos,,, Win
return WinExist(WinTitle . " ahk_id " . Win)
}