/* Title: Bomenet Scene Switch Description: Create new or select old scene for use. AutoHotKey_L Version: 1.1.09.00 Written by: Steven J. Caldwell Last Update: 2024-02-15 Other Notes: For selecting a new Scene: Original running .bmts file is saved in Temp with a date and time stamp when selecting a new scene. It will overwrite if already created. Bome Network will be stopped and restarted. For creating a new Scene from the running file: If no file extension is input when creating a new scene it will be added. If the filename entered exists it will not be created. */ ; Command Line Options go here Modify as necessary /* Uncomment this section if you will be using arguments if 0 < x ; Change x to the number of required arguments { MsgBox 0,Usage,Usage is:`n } else { ; Do something here } */ ;Start Code below this line FileDir:= "%AppData%" . "\Bome\" TempDir:= "%TEMP%" . "\" EnvGet,DestDir,TEMP EnvGet,SourceDir,AppData ; SetWorkingDir, D:\Steve\Documents\AutoHotkey ; MsgBox %FileDir% ;ExitApp Gui, New, , Change BomeNetwork Scenes Gui, Font,s20 Gui, Add, Text, x10 , Select a preset scene file Gui, Add, Button,gSelect x+10 , Select Gui, Add, Text,y+10 x10, Save a preset scene file Gui, Add, Edit,vNewFile w300 x10 y+10, BomeNetScene Gui, Add, Button,gSave,Save Gui, Add, Button,gCancel,Cancel Gui, Show Return ExitApp GuiClose: ExitApp Cancel: ExitApp Save: Gui Submit Gui Hide Found := Instr(NewFile,".bmts") if (!Found) { NewFile:= NewFile . ".bmts" } ; MsgBox, New file is %NewFile% Source:= SourceDir . "\Bome\BomeNet.bmts" Dest:= SourceDir . "\Bome\" . NewFile ; MsgBox %Source% `n%Dest% FileCopy, %Source%, %Dest% if ErrorLevel { Msgbox Could not create new scene - %NewFile%`nMaybe it exists } ExitApp Select: Gui Hide FileSelectFile,NewConfig,,%FileDir%,Enter the file that you want,BomeNet*.bmts ; MsgBox, %NewConfig% Selected DetectHiddenWindows, On Process, Exist, BomeNet.exe NewPID = %ErrorLevel% ; Save the value immediately since ErrorLevel is often changed.) if NewPID = 0 ; i.e. it's not blank or zero. { Msgbox, ,Bome Scene, Bome Network Not running, 2 ;ExitApp } else { ; Msgbox,,, Killing Bome Network,2 Process, Close, BomeNet.exe Process, WaitClose, BomeNet.exe,5 if ErrorLevel { Msgbox,,, Could not kill Bome Network, 2 ExitApp } } ; Save old file FormatTime, ShortDate,A_Now,yyyy-MMM-d-HH-mm Dest:= DestDir . "\BomeNet-" . ShortDate . ".bmts" Source:= SourceDir . "\Bome\BomeNet.bmts" ;Msgbox, Source=`"%Source%`" Dest=`"%Dest%`" ;ExitApp FileCopy, %Source%, %Dest%, 1 if ErrorLevel { Msgbox,, Error, Could not copy old file,5 } ; Copy New File Dest:= SourceDir . "\Bome\BomeNet.bmts" Source:= NewConfig ; Msgbox, Source=`"%Source%`" Dest=`"%Dest%`" ; ExitApp FileCopy, %Source%, %Dest%, 1 if ErrorLevel { Msgbox,, Error, Could not copy new file,5 } ;; Startup Bome Network Run, "C:\Program Files (x86)\Bome Network\BomeNet.exe",,,PID if (ErrorLevel = "ERROR") { MsgBox, Could not Start Bome Network } else { ;MsgBox,,, Bome Network Restarted PID = %PID%, 5 } ExitApp /* !q:: ExitApp ;End Standard Code here ;Includes here