forked from camerb/AHKs
-
Notifications
You must be signed in to change notification settings - Fork 38
/
FcnLib-Nightly (BaustianVM's conflicted copy 2012-10-08).ahk
194 lines (166 loc) · 5.56 KB
/
FcnLib-Nightly (BaustianVM's conflicted copy 2012-10-08).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
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
#include FcnLib.ahk
;Function lib for things that are too ghetto to happen during the day
;{{{Basic Functions ( like RunIMacro() )
;TODO turn this into something that is suitable to post as a lib
;TODO needs better paths
;TODO needs to depend on fewer libs
;TODO error message is imacros is not installed
;TODO error message if firefox is not installed
;TODO add in a "hide" option that will winhide the window
;TODO needs unit tests
RuniMacro(script="URL GOTO=nascar.com", options="")
{
;vars we'll use later
firefoxWindow=Mozilla Firefox ahk_class Mozilla(UI)?WindowClass
;make the lockfile
startTime := CurrentTime("hyphenated")
lockfile := GetPath("imacro.lock")
FileCreate(startTime, lockfile)
;tweak the script so that is will cooperate/communicate with AHK
iMacroFile=%A_MyDocuments%\iMacros\Macros\ahkScripted.iim
/*
TAB CLOSEALLOTHERS
TAB CLOSE
TAB T=1
*/
script=
(
TAB CLOSEALLOTHERS
TAB OPEN
TAB T=2
TAB CLOSEALLOTHERS
%script%
FILEDELETE NAME=%lockfile%
)
;figure out where the firefox install is
;ffList:="C:\Program Files\Mozilla Firefox 4.0 Beta 4\firefox.exe,C:\Program Files\Mozilla Firefox\firefox.exe,C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
;ffList:="C:\Dropbox\Programs\FirefoxPortable\FirefoxPortable.exe,C:\Program Files\Mozilla Firefox 4.0 Beta 4\firefox.exe,C:\Program Files\Mozilla Firefox\firefox.exe,C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
ffList:="C:\Program Files\Mozilla Firefox\firefox.exe,C:\Program Files (x86)\Mozilla Firefox\firefox.exe,C:\Dropbox\Programs\FirefoxPortable\FirefoxPortable.exe,C:\Program Files\Mozilla Firefox 4.0 Beta 4\firefox.exe"
Loop, parse, ffList, CSV
{
if FileExist(A_LoopField)
{
firefoxPath:=A_LoopField
break
}
}
;error out if there were issues finding the FF path
if NOT firefoxPath
errord("", "cannot find path for firefox", A_LineNumber, A_ThisFunc, A_ScriptName)
;get firefox version
firefoxVersion:=GetFirefoxVersion(firefoxPath)
;are we using the portable version?
;TODO ugh... the portable version causes so many problems
if InStr(firefoxPath, "FirefoxPortable")
usingPortableVersion:=true
if usingPortableVersion
iMacroFile=C:\WINDOWS\Temp\iMacros\ahkScripted.iim
else
iMacroFile=%A_MyDocuments%\iMacros\Macros\ahkScripted.iim
FileCreate(script, iMacroFile)
Sleep, 1000
;if usingPortableVersion
;{
;ProcessCloseAll("firefox.exe")
;if NOT ProcessExist("FirefoxPortable.exe")
;Run, "%firefoxPath%"
;}
;else
;{
if NOT ProcessExist("firefox.exe")
Run, "%firefoxPath%"
;RunProgram("Firefox")
;}
;show the window in the correct location
ForceWinFocus(firefoxWindow)
Sleep, 1000
;WinMove, %firefoxWindow%, , 0, 0, 1766, 924
;FIXME something in here always makes it create a new firefox window on the home pc... why is that?
;run the iMacro
Run, "%firefoxPath%" http://run.imacros.net/?m=ahkScripted.iim
;wait for the lockfile to disappear, then we'll know that the imacro is done
WaitFileNotExist(lockfile)
;close the iMacros panel
;ToggleIMacrosPanel()
FileCreate("'this is where imacros are saved temporarily", iMacroFile)
Sleep, 1000
;Run this junk on the home PC, cause it's running cruddy old Firefox 3.6.24
if (ConvertVersionNumToInt(FirefoxVersion) < 5)
{
ForceWinFocus("Mozilla Firefox", "Exact")
WinClose("Mozilla Firefox", "Exact")
Sleep, 200
}
if ClickIfImageSearch("images/iMacros/iMacrosLargeLogo2.bmp")
{
;TODO shouldn't I move this down below the if?
ToggleIMacrosPanel()
}
}
iMacroUrlDownloadToVar(url="")
{
if (url != "")
GoToUrlCommand=URL GOTO=%url%
folder=C:\Dropbox\AHKs\gitExempt\
file=savedPageSource.html
path=%folder%%file%
imacro=
(
%GoToUrlCommand%
SAVEAS TYPE=HTM FOLDER=%folder% FILE=%file%
)
RuniMacro(imacro)
returned := FileRead(path)
FileDelete(path)
return returned
}
;I'm thinking this should generally be discouraged (the hotkey is configurable)
ToggleIMacrosPanel()
{
Sleep, 2000
ControlSend, , {F8}, Mozilla Firefox
;Send, {F8}
Sleep, 2000
}
;}}}
;{{{ Mint Functions
MintLogIn()
{
panther:=SexPanther()
imacro=
(
VERSION BUILD=7300701 RECORDER=FX
URL GOTO=https://wwws.mint.com/login.event?task=L
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:loginUserSubmit.xevent ATTR=ID:form-login-username [email protected]
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ACTION:loginUserSubmit.xevent ATTR=ID:form-login-password CONTENT=%panther%
TAG POS=1 TYPE=LI ATTR=ID:log_in
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:form-login ATTR=VALUE:Log<SP>In
TAG POS=1 TYPE=A ATTR=TXT:Transactions
URL GOTO=https://wwws.mint.com/transaction.event
)
RuniMacro(imacro)
}
MintGetTransactionCsvs()
{
imacro=
(
VERSION BUILD=7300701 RECORDER=FX
URL GOTO=https://wwws.mint.com/transaction.event
TAG POS=1 TYPE=A ATTR=TXT:Transactions
ONDOWNLOAD FOLDER=C:\Dropbox\AHKs\GitExempt\mint_export\ FILE={{!NOW:yyyy-mm-dd}}.csv WAIT=YES
TAG POS=1 TYPE=A ATTR=ID:transactionExport
)
RuniMacro(imacro)
}
MintTouch()
{
imacro=
(
VERSION BUILD=7300701 RECORDER=FX
URL GOTO=https://wwws.mint.com/overview.event
TAG POS=1 TYPE=A ATTR=ID:module-accounts-update
)
RuniMacro(imacro)
}
;}}}