-
Notifications
You must be signed in to change notification settings - Fork 5
/
Launch_Pulover's_Macro_Recorder.ahk
83 lines (77 loc) · 2.43 KB
/
Launch_Pulover's_Macro_Recorder.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
#Requires Autohotkey v2.0
#SingleInstance Force
#Include lib\convert\ConvertFuncs.ahk
#Include lib\vars.ahk
#Include lib\loading.ahk
; If you are reading, and find use in this script
; please donate to the original creator https://www.macrocreator.com/donate/
loadingSplash(A_ScriptDir "\lib\loading.gif")
checkFirstTime(files)
Run(com, ,, &PID)
ProcessSetPriority "AboveNormal", PID
Sleep(1000)
findProcess(PID)
While ProcessExist(PID)
; while the Pulover's process exists
; wait for %logs% to exist, that means Pulover's is trying to generate code.
; this loop will convert to v2 and notify Pulover's via %retstat%
{
if FileExist(logs) ; check if the log file exists
{
inscript := tryRead(logs) ; read the contents of the file into a variable
if (inscript != "") ; if the variable is not empty
{
FileMove(logs, temps, 1) ; move the log file to the temporary file
try
{
script := Convert(inscript) ; convert the script from AHK v1 to AHK v2 ; add menu handlers to the script
,FileCopy(empty, temps, 1)
,FileAppend(script, temps)
,FileCopy(temps, retstat, 1)
,FileMove(temps, trash, 1)
}
catch as e {
errorLog(e.message)
sleep(10)
} } }
else {
Sleep(15)
continue
}
}
ExitApp
errorLog(str)
{
FileOpen("lib\error.txt", "w").Write(str "`n`n")
}
checkFirstTime(files)
{
ft := A_ScriptDir "\lib\firstTime.txt"
if !FileExist(ft)
{
MsgBox("This is your first time. If Pulover's Macro Creator needs to download language packs, `nexpect the need to restart from the `"Launch_Pulover's_Macro_Recorder.ahk`" after update.`n`nThis also MAY CAUSE FREEZES even for advanced systems. Please be patient it'll take less than a minute. ")
FileAppend("test", ft)
}
}
findProcess(PID)
{
Loop 250 { ; loop up to 10 times
if ProcessExist(PID) { ; check if the AutoGUI process exists
break ; if it does, break out of the loop
}
else {
Sleep(50) ; if it doesn't, wait for 1 second and check again
}
}
}
;try {out := FileRead(path)}
tryRead(path) {
try {
out := FileRead(path)
return out
}
catch {
Sleep(10)
return ""
}
}