Facebook
From Crippled Crow, 2 Years ago, written in Autohotkey.
Embed
Download Paste or View Raw
Hits: 255
  1.  
  2. #Requires AutoHotkey v2
  3. #Warn all, off
  4.  
  5.  
  6. G := MyGui_Create()
  7. ;this.object does not work directly under GUI for standard methods, used G global instead
  8.  
  9.  
  10. class MyGui_Create
  11. {
  12.         __New() {
  13.                 this.MyGui := Gui(, "Launcher")
  14.                 Grp1 := this.MyGUI.AddGroupBox("x7 y4 w267 h93", ".venv")
  15.                 this.launch := this.MyGUI.AddButton("x22 y40 w102 h23", "&Launch")
  16.                 this.launch.OnEvent("Click", this.launch_click)
  17.                
  18.                 this.create := this.MyGUI.AddButton("x151 y40 w102 h23", "&Create")
  19.                 this.create.OnEvent("Click", this.create_click)
  20.                
  21.                 this.Grp2 := this.MyGUI.AddGroupBox("x11 y98 w277 h190", "Installers")
  22.                 this.Nuitka := this.MyGUI.AddButton("x20 y137 w102 h25", "&Nuitka")
  23.                 this.Nuitka.OnEvent("Click", this.Nuitka_Click)
  24.                
  25.                 this.autopytoexe := this.MyGUI.AddButton("x152 y137 w101 h23", "&AutoPytoEXE")
  26.                 this.autopytoexe.OnEvent("Click", this.autopytoexe_Click)
  27.                
  28.                 this.CXFreeze := this.MyGUI.AddButton("x19 y176 w101 h23", "&CXFreeze")
  29.                 this.CXFreeze.OnEvent("Click", this.CXFreeze_Click)
  30.                
  31.                 this.PyInstaller := this.MyGUI.AddButton("x152 y176 w101 h23", "PyInstaller")
  32.                 this.PyInstaller.OnEvent("Click", this.PyInstaller_Click)
  33.                 this.PID := false
  34.                 this.activate_bat := false
  35.                 this.MyGui.Show("w300 h300")
  36.  
  37.         }
  38.         launch_click(*) {
  39.                 if (G.PID = 0) {
  40.                         G.ifnotpid()
  41.                 }
  42.                 G.findNearest_venv_Folder()
  43.                 G.activator()
  44.                 ; Send the text to the inactive Notepad edit control.
  45.                 ; The third parameter is omitted so the last found window is used.
  46.         }
  47.         create_click(*) {
  48.                 G.has_command_window_been_launched(1)
  49.                 ; Send the text to the inactive Notepad edit control.
  50.                 ; The third parameter is omitted so the last found window is used.
  51.                 G.ControlSendTextToCMD("python -m venv venv")
  52.                 G.sendEnter()
  53.                 G.findNearest_venv_Folder()
  54.                 WinActivate "ahk_pid " G.PID  ; Show the result.
  55.                 sleep(10000)
  56.                 G.activator()
  57.         }
  58.         Nuitka_click(*) {
  59.                 G.has_command_window_been_launched()
  60.                 ; Send the text to the inactive Notepad edit control.
  61.                 ; The third parameter is omitted so the last found window is used.
  62.                 G.ControlSendTextToCMD("pip install nuitka")
  63.                 G.sendEnter()
  64.                 G.findNearest_venv_Folder()
  65.                 G.WinAct()
  66.                 sleep(500)
  67.                 G.ControlSendTextToCMD("python -m nuitka --onefile --windows-icon-from-ico=C:\Users\dower\Documents\icons\Python.ico .py")
  68.         }
  69.         autopytoexe_Click(*){
  70.                 G.has_command_window_been_launched()
  71.                 ; Send the text to the inactive Notepad edit control.
  72.                 ; The third parameter is omitted so the last found window is used.
  73.                 G.ControlSendTextToCMD("pip install auto-py-to-exe")
  74.                 G.sendEnter()
  75.                 G.findNearest_venv_Folder()
  76.                 G.WinAct()
  77.                 sleep(500)
  78.                 G.WinAct()
  79.                 G.ControlSendTextToCMD("auto-py-to-exe")
  80.                 G.sendEnter()
  81.                 G.WinAct()
  82.         }
  83.         CXFreeze_Click(*){
  84.                
  85.                 G.has_command_window_been_launched()
  86.                 ; Send the text to the inactive Notepad edit control.
  87.                 ; The third parameter is omitted so the last found window is used.
  88.                 G.ControlSendTextToCMD("pip install cx-freeze")
  89.                 G.sendEnter()
  90.                 G.findNearest_venv_Folder()
  91.                 G.WinAct()
  92.                 sleep(500)
  93.                 G.WinAct()
  94.                 G.ControlSendTextToCMD("cxfreeze-quickstart")
  95.                 G.sendEnter()
  96.                 G.WinAct()
  97.         }
  98.         PyInstaller_Click(*){
  99.                 G.has_command_window_been_launched()
  100.                 ; Send the text to the inactive Notepad edit control.
  101.                 ; The third parameter is omitted so the last found window is used.
  102.                 G.ControlSendTextToCMD("pyinstaller --noconfirm --onefile --console --hidden-import `"PySimpleGUI`" --exclude-module `"tk-inter`" --hidden-import `"FileDialog`"  `"" A_ScriptDir "`"")
  103.                 G.WinAct()
  104.         }
  105.  
  106.         has_command_window_been_launched(M := 0){
  107.                 if (G.PID = 0) {
  108.                         G.ifnotpid()
  109.                 }
  110.                 if not (M = 1){
  111.                         G.findNearest_venv_Folder()
  112.                         G.activator()
  113.                 }
  114.         }
  115.         activator() {
  116.                 G.ControlSendTextToCMD(G.activate_bat)
  117.                 G.sendEnter()
  118.                 WinActivate "ahk_pid " G.PID  ; Show the result.
  119.         }
  120.         WinAct(){
  121.                 WinActivate "ahk_pid " G.PID
  122.         }
  123.  
  124.         findCMDWin() {
  125.                 if (G.activate_bat = 0) {
  126.                         Loop Files, A_ScriptDir "\*.*", "R"  ; Recurse into subfolders.
  127.                         {
  128.                                 if ("activate.bat" = A_LoopFileName) {
  129.                                         G.activate_bat := A_LoopFilePath
  130.                                         break
  131.                                 }
  132.                         }
  133.                 }
  134.                 else {
  135.                         return G.activate_bat
  136.                 }
  137.         }
  138.  
  139.         ifnotpid() {
  140.                         Run "cmd.exe", , "Min", &PID  ; Run Notepad minimized.
  141.                         WinWait "ahk_pid " PID  ; Wait for it to appear.
  142.                         G.PID := PID
  143.                 }
  144.         ControlSendText(text){
  145.                 ControlSendText(text, , "ahk_pid " G.PID)
  146.                 G.WinAct()
  147.         }
  148.         sendEnter(){
  149.                 ControlSend("{Enter}",, "ahk_pid " G.PID)
  150.         }
  151.  
  152. }
  153.  
  154. ;
  155.  
  156. ; class launch_click
  157. ; {
  158. ;       __new(){
  159. ;               this.cmdActive := false
  160. ;               this.PID := false
  161. ;               this.cmdActive := false
  162. ;               return
  163.  
  164. ;       }
  165. ;       launch(*) {
  166. ;               Run "cmd.exe", , "Min", &PID  ; Run Notepad minimized.
  167. ;               WinWait "ahk_pid " PID  ; Wait for it to appear.
  168. ;               this.PID := PID
  169.  
  170. ;               ; Send the text to the inactive Notepad edit control.
  171. ;               ; The third parameter is omitted so the last found window is used.
  172. ;               ControlSend "This is a line of text in the notepad window.{Enter}", , "ahk_pid " PID
  173. ;               ControlSendText "Notice that {Enter} is not sent as an Enter keystroke with ControlSendText.", , "ahk_pid " PID
  174. ;               ControlSend "{Enter}",, "ahk_pid " PID
  175. ;               Msgbox "Press OK to activate the window to see the result."
  176. ;               WinActivate "ahk_pid " PID  ; Show the result.
  177. ;       return
  178. ;       }
  179. ;       }
  180.