-
Notifications
You must be signed in to change notification settings - Fork 0
/
Window Police.ahk2
43 lines (42 loc) · 1.25 KB
/
Window Police.ahk2
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
39
40
41
42
43
/************************************************************************
* @description Prevent windows from stealing focus from the active window
* @file Window Police
* @author Taylor Ginis
* @date 2024/02/14
* @version 0.1
* @versioncodename Beta 1
***********************************************************************/
#Requires AutoHotkey v2.0+
#SingleInstance Force
Persistent()
InstallKeybdHook
myloop:
currentWindow:=WinActive('A')
bypass:
clicked := 2
if WinExist(currentWindow){
if !WinActive(currentWindow){
MouseGetPos(,,&WindowUnderMouse)
if WindowUnderMouse = currentWindow{
WinActivate(currentWindow)
goto bypass
}
if WindowUnderMouse != currentWindow{
if WindowUnderMouse = WinActive('A')
goto bypass
clicked:= KeyWait("Lbutton", "T2")
if clicked = 1 { ;user clicked mouse within 2 seconds
MouseGetPos(,,&newWindowUnderMouse)
WinActivate(newWindowUnderMouse)
currentWindow :=newWindowUnderMouse
clicked := 2
goto bypass
}
else if clicked = 0{
goto bypass
}
}
}
goto myloop
}
goto myloop