forked from aRTy42/POE-ItemInfo
-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bunch of fixes and error handling improvements (#470)
* fixed pre fill max value checkbox; added pseudomod exceptions to always be present * added context menu option to show assigned hotkeys * fixed advanced affix lookup * fixed poeaffix lookup for daggers * disabled forced 4/3L selection (advanced search) * added custom macro file example * custom acros example file improvements * rewrote file copy to user folder * example file changes * example file changes * example file changes * example file * added custom macros example to edit files context menu * improved run scripts error handling * added file write check for script dir * added call to custom macro code execution label * added more folder permission checks * more permission check stuff * file write permission issues error handling * grammar * fixed pseudo mods not showing added flat ele dmg * macro example file rework * fixed harbinger fragments/maps not being searchable * code refactoring * refactored run scripts: one checks version, one does the rest * added exit app to run scripts * added q20 pdps to ItemInfo tooltip * added poe.ninja request fallback and improved AHK version check * example file * improve run script compatibility with ahk v2 * added paypal link * added wiki link to additional macros * added config key for poeapp search * update note/version; fix file copy issue when using the dev version
- Loading branch information
Showing
23 changed files
with
827 additions
and
665 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,9 +62,6 @@ backup/* | |
backup/ | ||
test.ahk | ||
|
||
config.ini | ||
config_trade.ini | ||
|
||
lib/node_modules | ||
lib/npm-debug.log.* | ||
release | ||
|
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,137 +1,14 @@ | ||
; #################################################################################################### | ||
; # This script merges PoE-ItemInfo and AdditionalMacros into one script and executes it. | ||
; # We also have to set some global variables and pass them to the ItemInfo script. | ||
; # This is to support using ItemInfo as dependancy for other tools. | ||
; #################################################################################################### | ||
#Include, %A_ScriptDir%\resources\Version.txt | ||
; ##################################################################################################################### | ||
; # This script checks if the right AHK version is installed and runs the ItemInfo merge script. | ||
; ##################################################################################################################### | ||
#Include %A_ScriptDir%\resources\Version.txt | ||
|
||
MsgWrongAHKVersion := "AutoHotkey v" . AHKVersionRequired . " or later is needed to run this script. `n`nYou are using AutoHotkey v" . A_AhkVersion . " (installed at: " . A_AhkPath . ")`n`nPlease go to http://ahkscript.org to download the most recent version." | ||
If (A_AhkVersion < AHKVersionRequired) | ||
{ | ||
MsgBox, 16, Wrong AutoHotkey Version, % MsgWrongAHKVersion | ||
ExitApp | ||
MsgWrongAHKVersion := "AutoHotkey v" . AHKVersionRequired . " or later is needed to run this script. It is important not to run version 2.x. `n`nYou are using AutoHotkey v" . A_AhkVersion . " (installed at: " . A_AhkPath . ")`n`nPlease go to http://ahkscript.org to download the most recent version." | ||
If (A_AhkVersion < AHKVersionRequired or A_AhkVersion >= "2.0.00.00") | ||
{ | ||
MsgBox, 16, Wrong AutoHotkey Version, % AHKVersionRequired | ||
ExitApp | ||
} | ||
|
||
RunAsAdmin() | ||
If (!PoEScripts_CreateTempFolder(A_ScriptDir, "PoE-ItemInfo")) { | ||
ExitApp | ||
} | ||
|
||
If (InStr(A_ScriptDir, A_Desktop)) { | ||
Msgbox, 0x1010, Invalid Installation Path, Executing PoE-ItemInfo from your Desktop may cause script errors, please choose a different directory. | ||
} | ||
|
||
/* | ||
Set ProjectName to create user settings folder in A_MyDocuments | ||
*/ | ||
projectName := "PoE-ItemInfo" | ||
FilesToCopyToUserFolder := ["\resources\config\default_config.ini", "\resources\ahk\default_AdditionalMacros.txt", "\resources\ahk\default_MapModWarnings.txt"] | ||
overwrittenFiles := PoEScripts_HandleUserSettings(projectName, A_MyDocuments, "", FilesToCopyToUserFolder, A_ScriptDir) | ||
isDevelopmentVersion := PoEScripts_isDevelopmentVersion() | ||
userDirectory := A_MyDocuments . "\" . projectName . isDevelopmentVersion | ||
|
||
PoEScripts_CompareUserFolderWithScriptFolder(userDirectory, A_ScriptDir, projectName) | ||
|
||
/* | ||
merge all scripts into `_ItemInfoMain.ahk` and execute it. | ||
*/ | ||
info := ReadFileToMerge(A_ScriptDir "\resources\ahk\POE-ItemInfo.ahk") | ||
addMacros := ReadFileToMerge(userDirectory "\AdditionalMacros.txt") | ||
|
||
info := info . "`n`r`n`r" | ||
addMacros := "#IfWinActive Path of Exile ahk_class POEWindowClass ahk_group PoEexe" . "`n`r`n`r" . addMacros | ||
addMacros .= AppendCustomMacros(userDirectory) | ||
|
||
CloseScript("ItemInfoMain.ahk") | ||
FileDelete, %A_ScriptDir%\_ItemInfoMain.ahk | ||
FileCopy, %A_ScriptDir%\resources\ahk\POE-ItemInfo.ahk, %A_ScriptDir%\_ItemInfoMain.ahk | ||
|
||
FileAppend, %addMacros% , %A_ScriptDir%\_ItemInfoMain.ahk | ||
|
||
; set script hidden | ||
FileSetAttrib, +H, %A_ScriptDir%\_ItemInfoMain.ahk | ||
; pass some parameters to ItemInfo | ||
Run "%A_AhkPath%" "%A_ScriptDir%\_ItemInfoMain.ahk" "%projectName%" "%userDirectory%" "%isDevelopmentVersion%" "%overwrittenFiles%" | ||
|
||
ExitApp | ||
|
||
|
||
; #################################################################################################### | ||
; # functions | ||
; #################################################################################################### | ||
|
||
CloseScript(Name) | ||
{ | ||
DetectHiddenWindows On | ||
SetTitleMatchMode RegEx | ||
IfWinExist, i)%Name%.* ahk_class AutoHotkey | ||
{ | ||
WinClose | ||
WinWaitClose, i)%Name%.* ahk_class AutoHotkey, , 2 | ||
If ErrorLevel | ||
Return "Unable to close " . Name | ||
Else | ||
Return "Closed " . Name | ||
} | ||
Else | ||
Return Name . " not found" | ||
} | ||
|
||
RunAsAdmin() | ||
{ | ||
ShellExecute := A_IsUnicode ? "shell32\ShellExecute":"shell32\ShellExecuteA" | ||
If Not A_IsAdmin | ||
{ | ||
If A_IsCompiled | ||
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_ScriptFullPath, str, A_WorkingDir, int, 1) | ||
Else | ||
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_AhkPath, str, """" . A_ScriptFullPath . """", str, A_WorkingDir, int, 1) | ||
ExitApp | ||
} | ||
} | ||
|
||
AppendCustomMacros(userDirectory) | ||
{ | ||
If(!InStr(FileExist(userDirectory "\CustomMacros"), "D")) { | ||
FileCreateDir, %userDirectory%\CustomMacros\ | ||
} | ||
|
||
appendedMacros := "`n`n" | ||
extensions := "txt,ahk" | ||
Loop %userDirectory%\CustomMacros\* | ||
{ | ||
If A_LoopFileExt in %extensions% | ||
{ | ||
FileRead, tmp, %A_LoopFileFullPath% | ||
appendedMacros .= "; appended custom macro file: " A_LoopFileName " ---------------------------------------------------" | ||
appendedMacros .= "`n" tmp "`n`n" | ||
} | ||
} | ||
|
||
Return appendedMacros | ||
} | ||
|
||
ReadFileToMerge(path) { | ||
If (FileExist(path)) { | ||
ErrorLevel := 0 | ||
FileRead, file, %path% | ||
If (ErrorLevel = 1) { | ||
; file does not exist (should be caught already) | ||
Msgbox, 4096, Critical file read error, File "%path%" doesn't exist.`n`nClosing Script... | ||
ExitApp | ||
} Else If (ErrorLevel = 2) { | ||
; file is locked or inaccessible | ||
Msgbox, 4096, Critical file read error, File "%path%" is locked or inaccessible.`n`nClosing Script... | ||
ExitApp | ||
} Else If (ErrorLevel = 3) { | ||
; the system lacks sufficient memory to load the file | ||
Msgbox, 4096, Critical file read error, The system lacks sufficient memory to load the file "%path%".`n`nClosing Script... | ||
ExitApp | ||
} Else { | ||
Return file | ||
} | ||
} Else { | ||
Msgbox, 4096, Critical file read error, File "%path%" doesn't exist.`n`nClosing Script... | ||
ExitApp | ||
} | ||
} | ||
Run "%A_AhkPath%" "%A_ScriptDir%\resources\ahk\Merge_ItemInfo.ahk" "%A_ScriptDir%" | ||
ExitApp |
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
PoE_Scripts_CheckFolderWriteAccess(Folder, critical = true) { | ||
access := FolderWriteAccess(Folder) | ||
|
||
msg := "The script is not able to write any file to " Folder ".`nYour user may not have the necessary permissions. " | ||
msg .= "While it may be possible to manually copy and create files in this folder it doesn't work programmatically.`n`n" | ||
msg .= "The reason for this could be your AntiVir software blocking Autohotkey from modifying files in this directory!" | ||
|
||
If (not access) { | ||
If (critical) { | ||
msg .= "`n`nClosing Script..." | ||
Msgbox, 0x1010, Critical permission error, % msg | ||
ExitApp | ||
} Else { | ||
Msgbox, 4096, Permission error, % msg | ||
} | ||
} | ||
Return access | ||
} | ||
|
||
FolderWriteAccess(Folder) { | ||
If InStr( FileExist(Folder), "D" ) { | ||
FileAppend,,%Folder%\fa.tmp | ||
rval := ! ErrorLevel | ||
FileDelete, %Folder%\fa.tmp | ||
Return rval | ||
} Return - 1 | ||
} | ||
|
||
|
Oops, something went wrong.