-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject.ahk
More file actions
124 lines (101 loc) · 2.52 KB
/
Copy pathobject.ahk
File metadata and controls
124 lines (101 loc) · 2.52 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
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#SingleInstance force
GetMonitor(hwnd := 0) {
; If no hwnd is provided, use the Active Window
if (hwnd)
{
WinGetPos, winX, winY, winW, winH, ahk_id %hwnd%
}
else
{
WinGetActiveStats, winTitle, winW, winH, winX, winY
}
SysGet, numDisplays, MonitorCount
SysGet, idxPrimary, MonitorPrimary
Loop %numDisplays%
{
SysGet, mon, MonitorWorkArea, %a_index%
leftShift := 0
rightShift := 0
; Left may be skewed on Monitors past 1
if (a_index > 1)
{
leftShift := 20
}
; Right overlaps Left on Monitors past 1
else if (numDisplays > 1)
{
rightShift := 20
}
; Tracked based on X. Cannot properly sense on Windows "between" monitors
xMin := monLeft - leftShift
xMax := monRight - rightShift
if (winX >= xMin AND (winX + winW / 2) <= xMax)
{
return %a_index%
}
}
; Return Primary Monitor if can't sense
return idxPrimary
}
global pdf_window_id := -1
IsMSWindow(title) {
WinGetClass, class, %title%,
if (class = "OpusApp") {
return true
}
return false
}
IsPDFClass(active_class) {
if (active_class == "AcrobatSDIWindow") {
return true
}
return false
}
FindPDFWindow() {
; TODO: Make a way to reset the pdf_window_id without restarting
; and find a good key to bind it to.
global pdf_window_id
; Check if the window is still valid
IfWinNotExist, ahk_id %pdf_window_id%
{
pdf_window_id = -1
}
; If we don't have a valid window,
; then we better find it!
if (pdf_window_id == -1) {
; First check if our active window is good.
; This way we choose the active pdf if more than one are open
WinGetClass, active_class, A
if (IsPDFClass(active_class)) {
WinGet, pdf_window_id, ID, ahk_class %active_class%
}
; If we didn't find it in the last try,
; loop through the available windows and pick one
if (pdf_window_id == -1) {
WinGet, id, list,,, Program Manager
Loop, %id%
{
this_id := id%A_Index%
WinGetClass, active_class, ahk_id %this_id%
if (IsPDFClass(active_class)) {
WinGet, pdf_window_id, ID, ahk_class %active_class%
}
}
}
}
return pdf_window_id
}
; GetOneNoteID() {
; See if we can find a window that is a OneNote Window
; We will return the ID of this window
; WinGet, onenote_id, ProcessName, , ahk_class ONENOTE,
; MsgBox, ID is "%onenote_id%"
; if (%onenote_id%) {
; MsgBox, Found ID
; } else {
; MsgBox, No Id again
; }
; return
; }
; GetOneNoteID()
; return