Bome Network - Scenes for Routing

Hello Windows users. I created the attached AutoHotKey script for changing Scenes on Bome Network. I believe at some point in the future Bome will add something similar (but probably better) but I didn’t want to wait.

The way it works is the users either opens a saved scene or saves the current configuration as a scene. Note, available ports are not changed, just the routing.

If the user opens a saved scene, the user is prompted for the scene name and can select the scene from %Appdata%\Bome\BomeNet*.bmts.
The current BomeNet.bmts file is saved in %TEMP% with a unique name (as a backup). Bome Network is then shut down.
Then the selected .bmts file is copied to %Appdata%\Bome\BomeNet.bmts. Then Bome Network is restarted and will read the new file as it’s current routing file.

If the user saves the current scene, then BomeNet.bmts is simply copied with the filename as the users choosing (without BMTS). By default it will be ‘BomeNetScene’ but you can give it the name of your choosing. The script automatically adds the ‘.bmts’. It is written in AutoHotKey v1.

Here it is.

/*
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

I’m also adding as an attachment .txt file that will be renamed with an extension of .ahk instead.

Bomenet-Scene-2024-02-15.txt (3.2 KB)

Note, this is not a Bome Product but just a user written script. Use at your own risk

Steve Caldwell
Bome Customer Care


Also available for paid consulting services: bome@sniz.biz