Skip to content

Commit e312e2e

Browse files
authored
Update Final.ahk
1 parent da14830 commit e312e2e

File tree

1 file changed

+86
-119
lines changed

1 file changed

+86
-119
lines changed

Other/7zEmuPrepper/Final.ahk

Lines changed: 86 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,107 @@
11
#Requires AutoHotkey v2.0
2-
3-
; ============================================================================
4-
; 7zEmuPrepper Configuration GUI
5-
; Generates command line for 7zEmuPrepper.ps1
6-
; ============================================================================
7-
8-
#Warn
92
#SingleInstance
103

11-
; Initialize variables
4+
; 7zEmuPrepper command builder (for 7zEmuPrepper.ps1)
5+
; Fields -> emits a ready-to-run PowerShell command. Includes a Copy button.
6+
127
sevenZEmuPrepperPath := ""
138
sevenZipPath := ""
14-
EmulatorPath := ""
15-
Arguments := ""
16-
ExtractionPath := ""
17-
GamePath := ""
18-
Extensions := ""
19-
KeepExtracted := false
20-
21-
; Create GUI
22-
myGui := Gui("+AlwaysOnTop", "7zEmuPrepper Configuration")
23-
24-
; GroupBox and Edit controls
25-
myGui.Add("GroupBox", "x22 y340 w430 h90", "Batch output")
26-
OutputEdit := myGui.Add("Edit", "ReadOnly x32 y355 w410 h70 vOutput")
27-
28-
myGui.Add("GroupBox", "x2 y19 w150 h30", "7zEmuPrepperPath")
29-
Edit7zEmuPrepper := myGui.Add("Edit", "x2 y34 w130 h20 v7zEmuPrepperPath")
30-
Btn7zEmuPrepper := myGui.Add("Button", "x132 y34 w20 h20", "F")
31-
32-
myGui.Add("GroupBox", "x2 y60 w150 h30", "7ZipPath")
33-
Edit7Zip := myGui.Add("Edit", "x2 y75 w130 h20 v7ZipPath")
34-
Btn7Zip := myGui.Add("Button", "x132 y75 w20 h20", "F")
35-
36-
myGui.Add("GroupBox", "x2 y101 w150 h30", "EmulatorPath")
37-
EditEmulator := myGui.Add("Edit", "x2 y116 w130 h20 vEmulatorPath")
38-
BtnEmulator := myGui.Add("Button", "x132 y116 w20 h20", "F")
39-
40-
myGui.Add("GroupBox", "x2 y142 w150 h30", "Arguments")
41-
EditArguments := myGui.Add("Edit", "x2 y157 w130 h20 vArguments")
42-
43-
myGui.Add("GroupBox", "x2 y183 w150 h30", "ExtractionPath")
44-
EditExtraction := myGui.Add("Edit", "x2 y198 w130 h20 vExtractionPath")
45-
BtnExtraction := myGui.Add("Button", "x132 y198 w20 h20", "F")
46-
47-
myGui.Add("GroupBox", "x2 y224 w150 h30", "GamePath")
48-
EditGame := myGui.Add("Edit", "x2 y239 w130 h20 vGamePath")
49-
BtnGame := myGui.Add("Button", "x132 y239 w20 h20", "F")
50-
51-
myGui.Add("GroupBox", "x2 y265 w150 h30", "Extensions")
52-
EditExtensions := myGui.Add("Edit", "x2 y280 w130 h20 vExtensions")
53-
54-
CheckKeep := myGui.Add("CheckBox", "x2 y305 w130 h30 vKeepExtracted", "KeepExtracted")
55-
56-
; Set event handlers
57-
Edit7zEmuPrepper.OnEvent("Change", UpdateOutput)
58-
Edit7Zip.OnEvent("Change", UpdateOutput)
59-
EditEmulator.OnEvent("Change", UpdateOutput)
60-
EditArguments.OnEvent("Change", UpdateOutput)
61-
EditExtraction.OnEvent("Change", UpdateOutput)
62-
EditGame.OnEvent("Change", UpdateOutput)
63-
EditExtensions.OnEvent("Change", UpdateOutput)
64-
CheckKeep.OnEvent("Click", UpdateOutput)
65-
66-
Btn7zEmuPrepper.OnEvent("Click", Select7zEmuPrepper)
67-
Btn7Zip.OnEvent("Click", Select7Zip)
68-
BtnEmulator.OnEvent("Click", SelectEmulator)
69-
BtnExtraction.OnEvent("Click", SelectExtraction)
70-
BtnGame.OnEvent("Click", SelectGame)
71-
72-
myGui.OnEvent("Close", (*) => ExitApp())
73-
74-
myGui.Show("h480 w640")
9+
emulatorPath := ""
10+
arguments := ""
11+
extractionPath := ""
12+
archivePath := ""
13+
extensions := ""
14+
keepExtracted := false
15+
16+
gui := Gui("+AlwaysOnTop", "7zEmuPrepper Config")
17+
gui.OnEvent("Close", (*) => ExitApp())
18+
19+
gui.Add("GroupBox", "x10 y330 w460 h90", "Command")
20+
outputEdit := gui.Add("Edit", "ReadOnly x20 y350 w440 h60 vOutput")
21+
22+
fields := [
23+
["7zEmuPrepper.ps1", "x10 y20 w150 h30", "x10 y40 w390 h23", "vPrepper"],
24+
["7Zip exe", "x10 y70 w150 h30", "x10 y90 w390 h23", "vSevenZip"],
25+
["Emulator exe", "x10 y120 w150 h30","x10 y140 w390 h23", "vEmu"],
26+
["Emu Arguments", "x10 y170 w150 h30","x10 y190 w390 h23", "vArgs"],
27+
["Extraction dir", "x10 y220 w150 h30","x10 y240 w390 h23", "vExtract"],
28+
["Archive file", "x10 y270 w150 h30","x10 y290 w390 h23", "vArchive"],
29+
["Launch ext(s)", "x10 y320 w150 h30","x10 y340 w390 h23", "vExt"]
30+
]
31+
32+
for f in fields {
33+
gui.Add("GroupBox", f[2])
34+
gui.Add("Edit", f[3] . " w370").OnEvent("Change", UpdateOutput)
35+
gui.Add("Button", "x405 y" . SubStr(f[3], 6, 2) . " w35 h23", "").OnEvent("Click", (btn,*) => SelectFileOrDir(btn))
36+
}
7537

76-
; Event handler functions
77-
UpdateOutput(*) {
78-
global
79-
sevenZEmuPrepperPath := Edit7zEmuPrepper.Value
80-
sevenZipPath := Edit7Zip.Value
81-
EmulatorPath := EditEmulator.Value
82-
Arguments := EditArguments.Value
83-
ExtractionPath := EditExtraction.Value
84-
GamePath := EditGame.Value
85-
Extensions := EditExtensions.Value
86-
KeepExtracted := CheckKeep.Value
38+
keepCB := gui.Add("CheckBox", "x20 y430 w200 h23 vKeep", "KeepExtracted")
39+
keepCB.OnEvent("Click", UpdateOutput)
8740

88-
keepFlag := KeepExtracted ? " -KeepExtracted" : ""
41+
copyBtn := gui.Add("Button", "x240 y430 w80 h23", "Copy")
42+
copyBtn.OnEvent("Click", (*) => (A_Clipboard := outputEdit.Value))
8943

90-
outputText := ' "' . sevenZEmuPrepperPath . '" "' . sevenZipPath . '" "'
91-
. EmulatorPath . '" "' . Arguments . '" "' . ExtractionPath . '" "'
92-
. GamePath . '" "' . Extensions . '"' . keepFlag . "`r`n"
44+
gui.Add("Button", "x340 y430 w80 h23", "Exit").OnEvent("Click", (*) => ExitApp())
9345

94-
OutputEdit.Value := outputText
95-
}
46+
gui.Show("w480 h470")
47+
return
9648

97-
Select7zEmuPrepper(*) {
49+
SelectFileOrDir(btn) {
9850
global
99-
selected := FileSelect(3, , "Select 7zEmuPrepper.ps1")
100-
if (selected != "") {
101-
Edit7zEmuPrepper.Value := selected
102-
UpdateOutput()
51+
text := btn.Text
52+
if (text = "") {
53+
; infer based on label order
54+
idx := btn.Hwnd
10355
}
10456
}
10557

106-
Select7Zip(*) {
107-
global
108-
selected := FileSelect(3, , "Select 7-Zip executable")
109-
if (selected != "") {
110-
Edit7Zip.Value := selected
111-
UpdateOutput()
112-
}
58+
; Simplified per-control selection based on Y position
59+
SelectFileOrDir(btn, *) {
60+
y := btn.Pos.Y
61+
if (y < 80) setVal("Prepper", FileSelect(3, , "Select 7zEmuPrepper.ps1"))
62+
else if (y < 130) setVal("SevenZip", FileSelect(3, , "Select 7z.exe"))
63+
else if (y < 180) setVal("Emu", FileSelect(3, , "Select emulator exe"))
64+
else if (y < 230) setVal("Args", InputBox("Enter emulator arguments (optional):").Value)
65+
else if (y < 280) setVal("Extract", DirSelect(, 3, "Select extraction folder"))
66+
else if (y < 330) setVal("Archive", FileSelect(3, , "Select archive"))
67+
else setVal("Ext", InputBox("Enter launch extensions (e.g. .iso,.bin):").Value)
68+
UpdateOutput()
11369
}
11470

115-
SelectEmulator(*) {
116-
global
117-
selected := FileSelect(3, , "Select emulator executable")
118-
if (selected != "") {
119-
EditEmulator.Value := selected
120-
UpdateOutput()
71+
setVal(name, val) {
72+
if (val = "" || val = null) return
73+
switch name {
74+
case "Prepper": ControlSetText(val, "Edit1")
75+
case "SevenZip": ControlSetText(val, "Edit2")
76+
case "Emu": ControlSetText(val, "Edit3")
77+
case "Args": ControlSetText(val, "Edit4")
78+
case "Extract": ControlSetText(val, "Edit5")
79+
case "Archive": ControlSetText(val, "Edit6")
80+
case "Ext": ControlSetText(val, "Edit7")
12181
}
12282
}
12383

124-
SelectExtraction(*) {
125-
global
126-
selected := DirSelect(, 3, "Select extraction folder")
127-
if (selected != "") {
128-
EditExtraction.Value := selected
129-
UpdateOutput()
130-
}
131-
}
132-
133-
SelectGame(*) {
134-
global
135-
selected := FileSelect(3, , "Select game archive")
136-
if (selected != "") {
137-
EditGame.Value := selected
138-
UpdateOutput()
84+
UpdateOutput(*) {
85+
prep := ControlGetText("Edit1")
86+
seven := ControlGetText("Edit2")
87+
emu := ControlGetText("Edit3")
88+
args := ControlGetText("Edit4")
89+
extract := ControlGetText("Edit5")
90+
arc := ControlGetText("Edit6")
91+
ext := ControlGetText("Edit7")
92+
keep := ControlGet("Keep").Value
93+
if (prep = "" || seven = "" || emu = "" || extract = "" || arc = "" || ext = "") {
94+
outputEdit.Value := ""
95+
return
13996
}
97+
keepFlag := keep ? " -KeepExtracted" : ""
98+
; Build quoted command
99+
cmd := 'powershell -ExecutionPolicy Bypass -File "' prep '" ' _
100+
+ '"' seven '" "' emu '" ' _
101+
+ '"' args '" ' _
102+
+ '"' extract '" ' _
103+
+ '"' arc '" ' _
104+
+ '"' ext '"' _
105+
+ keepFlag
106+
outputEdit.Value := cmd
140107
}

0 commit comments

Comments
 (0)