-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCamera2Script.ahk
More file actions
executable file
·204 lines (174 loc) · 5.79 KB
/
Copy pathCamera2Script.ahk
File metadata and controls
executable file
·204 lines (174 loc) · 5.79 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#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.
; Boiler plate above ^^^
CoordMode Pixel ; Interprets the coordinates below as relative to the screen rather than the active window.
#Persistent
; 0 = Dev
; 1 = Camera 1 PC
; 2 = Camera 2 PC
environment := 2
runClickRefresh := true
; timeout := 60000 ; 1 minute
timeout := 15000 ; 15 seconds
if environment = 1
{
manual := false
captureUtil := "C:\Program Files (x86)\MiniCap\minicap.exe"
chrome := "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
picDir := "C:\Users\NUCUSER\Dropbox\Camera\PC1\"
picFilename := "CameraPC1"
interval := 900000
; 1920 x 1080
loginPosX := 900
loginPosY := 690
emailAddress := "pathwaysocietycameras@outlook.com"
loginMethod := 1
}
else if environment = 2
{
manual := false
captureUtil := "C:\Program Files (x86)\MiniCap\minicap.exe"
chrome := "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
picDir := "C:\Users\NUC USER\Dropbox\Camera\PC2\"
picFilename := "CameraPC2"
interval := 900000
; 1920 x 1080
loginPosX := 900
loginPosY := 690
emailAddress := "pathwaysocietycameras@outlook.com"
loginMethod := 1
}
else ; Dev
{
manual := true
captureUtil := "C:\Program Files\MiniCap\minicap.exe"
chrome := "C:\Program Files\Google\Chrome\Application\chrome.exe"
picDir := "C:\Users\Quicken\Pictures\"
picFilename := "Dev"
interval := 120000
loginPosX := 600
loginPosY := 580
emailAddress := "pathwaysocietycameras@outlook.com"
loginMethod := 0
}
; 1 minute = 60000
; 15 minutes = 900000
SetTimer, RestartChrome, %interval%
SetTimer, ClickRefresh, 60000
^k::
ClickRefresh()
;FindPic("usethisaccount.png")
return
^j::
RestartChrome()
return
; --------------------------------------------------------
; ClickRefresh
; If a given image doesn't load, a "Refresh?" link appears.
; For now, blindly click where each button could be.
; A HUD will appear but goes away after a moment.
; --------------------------------------------------------
ClickRefresh()
{
global runClickRefresh
if (runClickRefresh)
{
click 400, 400
click 1000, 400
click 1600, 400
click 400, 760
click 1000, 760
click 1600, 760
}
}
; --------------------------------------------------------
; LoginWithMicrosoft
; --------------------------------------------------------
LoginWithMicrosoft(method, email)
{
if (method = 1)
{
; Micorsoft switched back to 2018 behavior on 4/22/2020 @ 6pm PT.
; Micorsoft made a change on 4/23/2019 @ 9am PT that obviated the need for this code.
;; Micorsoft made a change on 12/20/2018 that necessitated this change.
;; Need to type in the email address and not actually sign in.
; Wait for the signin screen
; Enter email address and press enter
; Password is not needed.
FindPic("signinwithmicrosoft.png")
Send %email%{enter}
}
}
RestartChrome()
{
global manual
global captureUtil
global chrome
global picDir
global picFilename
global interval
global loginPosX
global loginPosY
global emailAddress
global runClickRefresh
global loginMethod
runClickRefresh := false
run %captureUtil% -save "%picDir%%picFilename% %A_YYYY%-%A_MM%-%A_DD% at %A_Hour%.%A_Min%.%A_Sec% A.jpg" -capturescreen -exit -compress 2 -convert gray
sleep, 1000 ; DelayInMilliseconds (Next command is too fast and Chrome is already closed)
WinClose, ahk_exe chrome.exe
run %chrome%
FindPic("logonwithmicrosoft.png")
; Click on "Log on with Microsoft" on the Comcast Business screen
click %loginPosX%, %loginPosY%
LoginWithMicrosoft(loginMethod, emailAddress)
sleep, 20000 ; DelayInMilliseconds
run %captureUtil% -save "%picDir%%picFilename% %A_YYYY%-%A_MM%-%A_DD% at %A_Hour%.%A_Min%.%A_Sec% B.jpg" -capturescreen -exit -compress 2 -convert gray
sleep, 1000 ; Weird, give time for nircmd to complete
runClickRefresh := true
}
; --------------------------------------------------------
; Find a image on the screen or exit after timeout value
; --------------------------------------------------------
FindPic(file)
{
global timeout
global picDir
global captureUtil
global picFilename
before := A_TickCount
done := false
loop {
ImageSearch, FoundX, FoundY, 450, 240, 1200, 800, %file%
if ErrorLevel = 2
MsgBox FindPic: Could not conduct the search for %file%.
else if ErrorLevel = 1
{
; MsgBox FindPic: Image %file% could not be found on the screen.
}
else
{
; MsgBox FindPic: The image was found at %FoundX%x%FoundY%.
done := true
}
after := A_TickCount
diff := after - before
if (done) or (diff >= timeout)
{
if (diff >= timeout)
{
; What was on the screen at the time of the timeout?
; Use this screenshot to generate new slug to look for
; %file% must end in png. jpg has too much compression and images won't work.
run %captureUtil% -save "%picDir%%picFilename% %A_YYYY%-%A_MM%-%A_DD% at %A_Hour%.%A_Min%.%A_Sec% %file%" -capturescreen -exit
}
break
}
FormatTime, dt, A_Now, ShortDate
FormatTime, tm, A_Now, Time
logMsg = %dt% %tm% %diff%`n
FileAppend %logMsg%, %picDir%%file%.txt
; MsgBox Time lapse %diff%, %FoundX%, %FoundY%
}
}