Code: Select all
xmlFile := "R:\tools\My Tools\Romhacking.net\Gen Hack Table.xml"
outDir := "R:\tools\My Tools\Romhacking.net\Gen Hack Table"
saveDialogWinTitle := "Save As ahk_class #32770"
dlDialogWinTitle := "File Download ahk_class #32770"
;FixIE()
fArr := []
Loop, Files, % dlDir "\*.*"
fArr.Push(A_LoopFileName)
Gui, Add, ActiveX, vwb w500 h500, Shell.Explorer.2
wb.Silent := true
Navigate("about:blank")
Gui, Show
xml := LoadXML(xmlFile)
games := xml.SelectNodes("//game")
for game in games
{
title := game.SelectSingleNode("@name").value
Navigate(game.SelectSingleNode("./dl").text)
text := wb.document.getElementsByClassName("note")[0].textContent
text := SubStr(text, StrLen(text) - 32, 32)
wb.document.querySelector("#passwrd").value := text
wb.document.querySelector("#I_am_Human").click()
WinWait, % dlDialogWinTitle
WinActivate, % dlDialogWinTitle
ControlGetText, dlFileName, SysLink1, % dlDialogWinTitle
MsgBox, % dlFileExt := SubStr(dlFileName, -2)
title := FixFileName(title)
if (FileExist(outFile := outDir "\" title "." dlFileExt)) {
ControlClick, Button3, % dlDialogWinTitle
Sleep, 250
} else {
ControlClick, Button2, % dlDialogWinTitle
WinWait, % saveDialogWinTitle
WinActivate, % saveDialogWinTitle
Control, EditPaste, % outFile, Edit1, % saveDialogWinTitle
ControlClick, Button2, % saveDialogWinTitle
Sleep, 500
}
}
return
Esc::
GuiClose:
ExitApp
Navigate(url) {
global wb
wb.navigate(url)
while (wb.ReadyState != 4)
sleep, 1000
}
LoadXML(file) {
xml := ComObjCreate("MSXML2.DOMDocument.6.0")
xml.async := false
if (FileExist(file))
xml.load(file)
else
xml.loadXML(file)
if (xml.parseError.errorCode != 0) {
xml := ""
MsgBox, % file "`ncan't load dom " xml.parseError.reason " on line " xml.parseError.line
return 0
}
xml.setProperty("SelectionLanguage", "XPath")
return xml
}
FixFileName(string) {
for i, v in ["<", ">", ":", """", "/", "|", "\", "?", "*"]
StringReplace, string, string, % v, % ""
return string
}
FixIE(Version=0, ExeName="")
{
static Key := "Software\Microsoft\Internet Explorer"
. "\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION"
, Versions := {7:7000, 8:8888, 9:9999, 10:10001, 11:11001}
if Versions.HasKey(Version)
Version := Versions[Version]
if !ExeName
{
if A_IsCompiled
ExeName := A_ScriptName
else
SplitPath, A_AhkPath, ExeName
}
RegRead, PreviousValue, HKCU, %Key%, %ExeName%
if (Version = "")
RegDelete, HKCU, %Key%, %ExeName%
else
RegWrite, REG_DWORD, HKCU, %Key%, %ExeName%, %Version%
return PreviousValue
}