-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathWindowSuperMaxStatus.ahk
66 lines (52 loc) · 2.01 KB
/
WindowSuperMaxStatus.ahk
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
WindowSuperMaxStatus(fnX,fnY,fnW,fnH)
{
; determines supermax (maxed across dual monitors) status of a window
; MsgBox fnX: %fnX%`nfnY: %fnY%`nfnW: %fnW%`nfnH: %fnH%
; declare local, global, static variables
Try
{
; set default return value
SuperMaxStatus := 0
; validate parameters
WinGetPos, TaskBarX, TaskBarY, TaskBarWidth, TaskBarHeight, ahk_class Shell_TrayWnd ; get taskbar positions and dimensions
If (TaskBarHeight > TaskBarWidth || TaskBarY < A_ScreenHeight/2) ; taskbar on side or top
{
SuperMaxStatus := -2
Throw, Exception("Taskbar on side or top")
}
SysGet, DualScreenW, 78 ; SM_CXVIRTUALSCREEN ; get total screen width (dual monitors)
If (DualScreenW = A_ScreenWidth)
{
SuperMaxStatus := -3
Throw, Exception("Not on dual monitors")
}
; initialise variables
EdgeToleranceInPixels := 10
; determine supermax status
If (fnX <= 0+EdgeToleranceInPixels)
If (fnY <= 0+EdgeToleranceInPixels)
If (fnW >= DualScreenW-EdgeToleranceInPixels-EdgeToleranceInPixels)
If (fnH >= A_ScreenHeight-TaskBarHeight-EdgeToleranceInPixels-EdgeToleranceInPixels)
SuperMaxStatus := 1
}
Catch, ThrownValue
{
CatchHandler(A_ThisFunc,ThrownValue.Message,ThrownValue.What,ThrownValue.Extra,ThrownValue.File,ThrownValue.Line,0,0,0)
}
Finally
{
}
; return
Return SuperMaxStatus
}
/* ; testing
WinGet, ThisWindowId, ID, ahk_class Notepad ; get active window ID
WinGetTitle, ThisWinTitle, ahk_id %ThisWindowId%
WinGetPos, npX, npY, npW, npH, ahk_id %ThisWindowId%
WinGetPos, TaskBarX, TaskBarY, TaskBarWidth, TaskBarHeight, ahk_class Shell_TrayWnd ; get taskbar positions and dimensions
SysGet, DualScreenW, 78 ; SM_CXVIRTUALSCREEN ; get total screen width (dual monitors)
abcH := A_ScreenHeight-TaskBarHeight
MsgBox, ThisWindowId: %ThisWindowId%`nThisWinTitle: %ThisWinTitle%`n%npX%,%npY%,%npW%,%npH%`nDualScreenW: %DualScreenW%`nA_ScreenHeight-TaskBarHeight: %abcH%
ReturnValue := WindowSuperMaxStatus(npX,npY,npW,npH)
MsgBox, WindowSuperMaxStatus`n`nSuperMaxStatus: %ReturnValue%
*/