As with all things that I post before thinking about, this one has already been mostly done. Heh. Okay. I've got two approaches now, utilizing only existing code. The first includes it all in one script, and the second makes one master script control other scripts that are running.
This first one isn't very flexible at all, but it does put it all in one script. It also allows for the transformation of scripts, kind of like what you can do with XML using XSL.
Code:
A:
{
; Insert script here.
}
B:
{
; Insert script here.
}
C:
{
; Insert script here.
}
#W:: ; This is for non-persistent scripts.
InputBox, RunScript, Run Script, Which child script should be run?
If RunScript =
return
Else
{
Gosub %RunScript%
return
}
This is one is quite flexible and uses a menu to control them. This could be changed to a gui. The downside is that this one requires extensive configuration just to simply add another script. If the concept interests you, I'll make a much more advanced version, that may allow adding a script without changing variables and structuring, and will have a configuration gui, and I'll give it it's own thread. However, I'd rather not take the effort if I'm way off base here. Feedback plz!
Code:
#Persistent
#SingleInstance
DetectHiddenWindows, on
SetTitleMatchMode, 2
; Once the script has been configured to handle a
; certain number of scripts, these variables are all
; that need to be changed.
Script1 = script1.ahk
Script2 = script2.ahk
Script3 = script3.ahk
Editor = notepad.exe
IfWinNotExist, %Script1% - AutoHotkey
Run, %Script1%
IfWinNotExist, %Script2% - AutoHotkey
Run, %Script2%
IfWinNotExist, %Script3% - AutoHotkey
Run, %Script3%
StringRight, Ext1, Script1, 4
StringRight, Ext2, Script2, 4
StringRight, Ext3, Script3, 4
StringTrimRight, Script1, Script1, 4
StringTrimRight, Script2, Script2, 4
StringTrimRight, Script3, Script3, 4
; Only thing that's wrong with this right now is
; there's no way to restart a script if it's exited.
; This, like many things, will be added if I remake
; the script.
Menu, tray, NoStandard
Menu, SuspendMenu, Add, &Suspend All, SA
Menu, SuspendMenu, Add
Menu, SuspendMenu, Add, &1 %Script1%, S1
Menu, SuspendMenu, Add, &2 %Script2%, S2
Menu, SuspendMenu, Add, &3 %Script3%, S3
Menu, tray, Add, &Suspend, :SuspendMenu
Menu, ReloadMenu, Add, &Reload All, RA
Menu, ReloadMenu, Add
Menu, ReloadMenu, Add, &1 %Script1%, R1
Menu, ReloadMenu, Add, &2 %Script2%, R2
Menu, ReloadMenu, Add, &3 %Script3%, R3
Menu, tray, Add, &Reload, :ReloadMenu
Menu, OpenMenu, Add, &1 %Script1%, O1
Menu, OpenMenu, Add, &2 %Script2%, O2
Menu, OpenMenu, Add, &3 %Script3%, O3
Menu, tray, Add, &Open, :OpenMenu
Menu, EditMenu, Add, &1 %Script1%, E1
Menu, EditMenu, Add, &2 %Script2%, E2
Menu, EditMenu, Add, &3 %Script3%, E3
Menu, tray, Add, &Edit, :EditMenu
Menu, ExitMenu, Add, Exit &Children, XC
Menu, ExitMenu, Add, Exit &Parent, XP
Menu, ExitMenu, Add, E&xit All, XA
Menu, ExitMenu, Add
Menu, ExitMenu, Add, %Script1%, X1
Menu, ExitMenu, Add, %Script2%, X2
Menu, ExitMenu, Add, %Script3%, X3
Menu, tray, Add, E&xit, :ExitMenu
Menu, tray, Add
Menu, tray, Add, &Window Spy, WS
Menu, tray, Add, &Text Editor, TE
StringReplace, Script1, Script1, %Script1%, %Script1%%Ext1%
StringReplace, Script2, Script2, %Script2%, %Script2%%Ext2%
StringReplace, Script3, Script3, %Script3%, %Script3%%Ext3%
return
SA:
PostMessage, 0x111, 65305,,,%Script1% - AutoHotkey
PostMessage, 0x111, 65305,,,%Script2% - AutoHotkey
PostMessage, 0x111, 65305,,,%Script3% - AutoHotkey
return
S1:
PostMessage, 0x111, 65305,,,%Script1% - AutoHotkey
return
S2:
PostMessage, 0x111, 65305,,,%Script2% - AutoHotkey
return
S3:
PostMessage, 0x111, 65305,,,%Script3% - AutoHotkey
return
RA:
PostMessage, 0x111, 65307,,,%Script1% - AutoHotkey
PostMessage, 0x111, 65307,,,%Script2% - AutoHotkey
PostMessage, 0x111, 65307,,,%Script3% - AutoHotkey
return
R1:
PostMessage, 0x111, 65303,,,%Script1% - AutoHotkey
return
R2:
PostMessage, 0x111, 65303,,,%Script2% - AutoHotkey
return
R3:
PostMessage, 0x111, 65303,,,%Script3% - AutoHotkey
return
O1:
PostMessage, 0x111, 65300,,,%Script1% - AutoHotkey
return
O2:
PostMessage, 0x111, 65300,,,%Script2% - AutoHotkey
return
O3:
PostMessage, 0x111, 65300,,,%Script3% - AutoHotkey
return
E1:
PostMessage, 0x111, 65304,,,%Script1% - AutoHotkey
return
E2:
PostMessage, 0x111, 65304,,,%Script2% - AutoHotkey
return
E3:
PostMessage, 0x111, 65304,,,%Script3% - AutoHotkey
return
XC:
PostMessage, 0x111, 65307,,,%Script1% - AutoHotkey
PostMessage, 0x111, 65307,,,%Script2% - AutoHotkey
PostMessage, 0x111, 65307,,,%Script3% - AutoHotkey
return
XP:
ExitApp
XA:
PostMessage, 0x111, 65307,,,%Script1% - AutoHotkey
PostMessage, 0x111, 65307,,,%Script2% - AutoHotkey
PostMessage, 0x111, 65307,,,%Script3% - AutoHotkey
ExitApp
X1:
PostMessage, 0x111, 65307,,,%Script1% - AutoHotkey
return
X2:
PostMessage, 0x111, 65307,,,%Script2% - AutoHotkey
return
X3:
PostMessage, 0x111, 65307,,,%Script3% - AutoHotkey
return
WS:
Run, C:\Program Files\AutoHotkey\AU3_Spy.exe
return
TE:
Run, %Editor%
return