forked from aRTy42/POE-ItemInfo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRun_ItemInfo.ahk
84 lines (71 loc) · 3.16 KB
/
Run_ItemInfo.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
; ####################################################################################################
; # 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.
; ####################################################################################################
FileRemoveDir, %A_ScriptDir%\temp, 1
FileCreateDir, %A_ScriptDir%\temp
#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
}
RunAsAdmin()
/*
Set ProjectName to create user settings folder in A_MyDocuments
*/
projectName := "PoE-ItemInfo"
FilesToCopyToUserFolder := ["\resources\config\default_config.ini", "\resources\ahk\default_AdditionalMacros.txt"]
overwrittenFiles := PoEScripts_HandleUserSettings(projectName, A_MyDocuments, "", FilesToCopyToUserFolder, A_ScriptDir)
isDevelopmentVersion := PoEScripts_isDevelopmentVersion()
userDirectory := A_MyDocuments . "\" . projectName . isDevelopmentVersion
/*
merge all scripts into `_ItemInfoMain.ahk` and execute it.
*/
FileRead, info , %A_ScriptDir%\resources\ahk\POE-ItemInfo.ahk
FileRead, addMacros , %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
CloseScript("ItemInfoMain.ahk")
FileDelete, %A_ScriptDir%\_ItemInfoMain.ahk
FileCopy, %A_ScriptDir%\resources\ahk\POE-ItemInfo.ahk, %A_ScriptDir%\_ItemInfoMain.ahk
FileAppend, %test% , %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
}
}