Last active
August 1, 2023 05:09
-
-
Save Ragnar-F/fa5887d011c0a2a8b49eb720ef6ace14 to your computer and use it in GitHub Desktop.
Lädt die neuesten deutschen Hilfedateien für AutoHotkey herunter und ersetzt die Hilfedateien im Installationsverzeichnis von AutoHotkey. Eine angepasste Version von https://www.autohotkey.com/boards/viewtopic.php?f=10&t=34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#SingleInstance ignore | |
#NoEnv | |
if not A_IsAdmin { | |
Run *RunAs "%A_ScriptFullPath%",, UseErrorLevel | |
if ErrorLevel { | |
MsgBox, 53, % "Adminrechte benötigt", % "Du musst den Updater mit Adminrechten starten, damit er richtig funktioniert!" | |
IfMsgBox, Retry | |
Reload | |
else | |
ExitApp | |
} | |
return | |
} | |
SplitPath, A_AhkPath,, AhkDir | |
try | |
{ | |
UpdateHelpFile("v1-de", AhkDir "\Autohotkey.chm") | |
if FileExist(AhkDir "\v2") | |
UpdateHelpFile("v2-de", AhkDir "\v2\Autohotkey.chm") | |
} | |
catch e | |
{ | |
MsgBox, 21, % "Fehler", % e.m "`n`nRepository: " e.r "`nZieldatei: " e.d | |
IfMsgBox, Retry | |
Reload | |
return | |
} | |
MsgBox, % "Neue deutsche Hilfe kopiert!" | |
return | |
UpdateHelpFile(repo, dest) | |
{ | |
e := {m: "", r: repo, d: dest} | |
ToolTip, % repo ": Hilfe wird heruntergeladen..." | |
UrlDownloadToFile, % "https://api.github.com/repos/autohotkey-docs-translation/" repo "/releases/latest", % A_Temp "\latest.json" | |
FileRead, latest, % A_Temp "\latest.json" | |
try | |
URLDownloadToFile, % JSON_parse(latest).assets.0.browser_download_url, %A_Temp%\AHKHelpDE.zip | |
catch | |
{ | |
e.m := "Fehler beim Herunterladen aufgetreten!" | |
throw e | |
} | |
ToolTip, % repo ": Hilfe wird entpackt..." | |
Unz(A_Temp "\AHKHelpDE.zip", A_Temp "\AHKHelpDE") | |
if not FileExist(A_Temp "\AHKHelpDE\Autohotkey.chm") { | |
e.m := "Fehler beim Entpacken aufgetreten!" | |
throw e | |
} | |
ToolTip, % repo ": Hilfe wird verschoben..." | |
try | |
FileMove, % A_Temp "\AHKHelpDE\Autohotkey.chm", % dest, 1 | |
catch | |
{ | |
e.m := "Fehler beim Verschieben aufgetreten! Fehlercode: " A_LastError | |
throw e | |
} | |
ToolTip, % repo ": Temporäre Dateien werden gelöscht..." | |
FileDelete, % A_Temp "\AHKHelpDE.zip" | |
FileDelete, % A_Temp "\latest.json" | |
FileRemoveDir, % A_Temp "\AHKHelpDE", 1 | |
ToolTip | |
return | |
} | |
JSON_parse(str) { ; https://www.autohotkey.com/boards/viewtopic.php?p=479280#p479280 | |
htmlfile := ComObjCreate("htmlfile") | |
htmlfile.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=edge"">") | |
return htmlfile.parentWindow.JSON.parse(str) | |
} | |
Unz(sZip, sUnz){ ; http://www.autohotkey.com/board/topic/60706-native-zip-and-unzip-xpvista7-ahk-l/ | |
fso := ComObjCreate("Scripting.FileSystemObject") | |
If Not fso.FolderExists(sUnz) ; http://www.autohotkey.com/forum/viewtopic.php?p=402574 | |
fso.CreateFolder(sUnz) | |
psh := ComObjCreate("Shell.Application") | |
zippedItems := psh.Namespace( sZip ).items().count | |
psh.Namespace( sUnz ).CopyHere( psh.Namespace( sZip ).items, 4|16 ) | |
Loop { | |
sleep 50 | |
unzippedItems := psh.Namespace( sUnz ).items().count | |
IfEqual,zippedItems,%unzippedItems% | |
break | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment