#Requires AutoHotkey v2
#Warn all, off
G := MyGui_Create()
;this.object does not work directly under GUI for standard methods, used G global instead
class MyGui_Create
{
__New() {
this
.MyGui
:= Gui(, "Launcher")
Grp1 := this.MyGUI.AddGroupBox("x7 y4 w267 h93", ".venv")
this.launch := this.MyGUI.AddButton("x22 y40 w102 h23", "&Launch")
this.launch.OnEvent("Click", this.launch_click)
this.create := this.MyGUI.AddButton("x151 y40 w102 h23", "&Create")
this.create.OnEvent("Click", this.create_click)
this.Grp2 := this.MyGUI.AddGroupBox("x11 y98 w277 h190", "Installers")
this.Nuitka := this.MyGUI.AddButton("x20 y137 w102 h25", "&Nuitka")
this.Nuitka.OnEvent("Click", this.Nuitka_Click)
this.autopytoexe := this.MyGUI.AddButton("x152 y137 w101 h23", "&AutoPytoEXE")
this.autopytoexe.OnEvent("Click", this.autopytoexe_Click)
this.CXFreeze := this.MyGUI.AddButton("x19 y176 w101 h23", "&CXFreeze")
this.CXFreeze.OnEvent("Click", this.CXFreeze_Click)
this.PyInstaller := this.MyGUI.AddButton("x152 y176 w101 h23", "PyInstaller")
this.PyInstaller.OnEvent("Click", this.PyInstaller_Click)
this.PID := false
this.activate_bat := false
this
.MyGui
.Show("w300 h300")
}
launch_click(*) {
if (G.PID = 0) {
G.ifnotpid()
}
G.findNearest_venv_Folder()
G.activator()
; Send the text to the inactive Notepad edit control.
; The third parameter is omitted so the last found window is used.
}
create_click(*) {
G.has_command_window_been_launched(1)
; Send the text to the inactive Notepad edit control.
; The third parameter is omitted so the last found window is used.
G.ControlSendTextToCMD("python -m venv venv")
G.sendEnter()
G.findNearest_venv_Folder()
G.activator()
}
Nuitka_click(*) {
G.has_command_window_been_launched()
; Send the text to the inactive Notepad edit control.
; The third parameter is omitted so the last found window is used.
G.ControlSendTextToCMD("pip install nuitka")
G.sendEnter()
G.findNearest_venv_Folder()
G.WinAct()
G.ControlSendTextToCMD("python -m nuitka --onefile --windows-icon-from-ico=C:\Users\dower\Documents\icons\Python.ico .py")
}
autopytoexe_Click(*){
G.has_command_window_been_launched()
; Send the text to the inactive Notepad edit control.
; The third parameter is omitted so the last found window is used.
G.ControlSendTextToCMD("pip install auto-py-to-exe")
G.sendEnter()
G.findNearest_venv_Folder()
G.WinAct()
G.WinAct()
G.ControlSendTextToCMD("auto-py-to-exe")
G.sendEnter()
G.WinAct()
}
CXFreeze_Click(*){
G.has_command_window_been_launched()
; Send the text to the inactive Notepad edit control.
; The third parameter is omitted so the last found window is used.
G.ControlSendTextToCMD("pip install cx-freeze")
G.sendEnter()
G.findNearest_venv_Folder()
G.WinAct()
G.WinAct()
G.ControlSendTextToCMD("cxfreeze-quickstart")
G.sendEnter()
G.WinAct()
}
PyInstaller_Click(*){
G.has_command_window_been_launched()
; Send the text to the inactive Notepad edit control.
; The third parameter is omitted so the last found window is used.
G.ControlSendTextToCMD("pyinstaller --noconfirm --onefile --console --hidden-import `"PySimpleGUI`" --exclude-module `"tk-inter`" --hidden-import `"FileDialog`" `"" A_ScriptDir "`"")
G.WinAct()
}
has_command_window_been_launched(M := 0){
if (G.PID = 0) {
G.ifnotpid()
}
if not (M = 1){
G.findNearest_venv_Folder()
G.activator()
}
}
activator() {
G.ControlSendTextToCMD(G.activate_bat)
G.sendEnter()
}
WinAct(){
}
findCMDWin() {
if (G.activate_bat = 0) {
{
G.activate_bat := A_LoopFilePath
}
}
}
else {
return G.activate_bat
}
}
ifnotpid() {
Run "cmd.exe", , "Min", &PID
; Run Notepad minimized.
WinWait "ahk_pid " PID
; Wait for it to appear.
G.PID := PID
}
ControlSendText
(text, , "ahk_pid " G
.PID
)
G.WinAct()
}
sendEnter(){
}
}
;
; class launch_click
; {
; __new(){
; this.cmdActive := false
; this.PID := false
; this.cmdActive := false
; return
; }
; launch(*) {
; Run "cmd.exe", , "Min", &PID ; Run Notepad minimized.
; WinWait "ahk_pid " PID ; Wait for it to appear.
; this.PID := PID
; ; Send the text to the inactive Notepad edit control.
; ; The third parameter is omitted so the last found window is used.
; ControlSend "This is a line of text in the notepad window.{Enter}", , "ahk_pid " PID
; ControlSendText "Notice that {Enter} is not sent as an Enter keystroke with ControlSendText.", , "ahk_pid " PID
; ControlSend "{Enter}",, "ahk_pid " PID
; Msgbox "Press OK to activate the window to see the result."
; WinActivate "ahk_pid " PID ; Show the result.
; return
; }
; }