 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
TodWulff
Joined: 29 Dec 2007 Posts: 99
|
Posted: Fri May 09, 2008 2:05 am Post subject: Reload Challenges |
|
|
I have an application script (the ARMbasic IDE) setup so that the user can reload the script if needed. And I AM making use of it a lot during my dev.
The vehicle of choice for doing this is via the reload command as I don't need to pass any command line parameters.
The script is setup with an onexit redirect to a subroutine that is shown below:
| Code: | _ExitIDE:
if VR_Initialized <> 0
ShutDown_VR()
Write_ini_Keys()
if (TTS_enabled = 1) {
Say("Saving Settings")
sleep 1000
}
Gui, 1:Destroy
If HostIDEContainerState <> 0
Gosub, ToggleIDEMI
if (TTS_enabled = 1) {
Say("Good Bye")
sleep 1500
}
if (ASD_Enabled = 1) {
ifwinexist %HostAppWinTitle% ahk_class %HostAppWinClass%
{
winwait %HostAppWinTitle% ahk_class %HostAppWinClass% ; wait for it to finish starting if close event happen at load .?.
winactivate %HostAppWinTitle% ahk_class %HostAppWinClass% ; and activate it
winwaitactive %HostAppWinTitle% ahk_class %HostAppWinClass% ; and wait for it to take focus
winclose %HostAppWinTitle% ahk_class %HostAppWinClass% ; once it is focused, close the damn thing
winwaitclose %HostAppWinTitle% ahk_class %HostAppWinClass% ; and wait for it to complete closing
}
}
COM_Term()
ExitApp
Return |
When the reload command is executed, the onexit sub is kicked off. Quite a bit is happening therein, shutting down the Voice Recognition COM resources, saving the config file (.ini), giving a verbal status update, etc.
What I am struggling with is this:
If TTS (Text To Speech) is enabled, and I take out the delays that I have there, the TTS code gets 1/2 way thru 1/2 of it's 1st syllable and then the COM wrapper code shuts down the COM faculties, and the TTS is abruptly halted.
However, if I have the delays therein (as reflected in the source), then the new instance of the script being instantiated sees that the old instance still running and offers up a confirmation dialoge about continuing to wait, or not.
...
Is there a way to tell the reload to halt a certain amount of time before actually instantiating the new instance? If so, please elaborate.
If not, does anyone have an idea on how to make it happen the way that I am wanting?
I am too close to the code, so I am prolly not seeing the forest thru the trees here...
Please advise. Thanks.
-t _________________ When replying, please feel free to address me as Tod or t. My AHK.net site... |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 676
|
Posted: Fri May 09, 2008 2:46 am Post subject: |
|
|
The code your executing on exit could be an outside scripot executed via a run command on exit
other than that then i plead stupidity _________________ Read this
Com
Automate IE7 with Tabs |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2558 Location: Australia, Qld
|
Posted: Fri May 09, 2008 9:19 am Post subject: |
|
|
I suggest you use #SingleInstance, Off and manually close the old instance of the script from the new instance. For example, run this script more than once:
| Code: | #Persistent
#SingleInstance, Off
; Hide the icon initially to avoid multiple icons in the tray.
#NoTrayIcon
DetectHiddenWindows, On
; List the main window HWND of all instances of this script.
; Omit "- AutoHotkey v%A_AhkVersion%" to allow compiled scripts.
WinGet, ScriptId, List, %A_ScriptFullPath% ahk_class AutoHotkey
Process, Exist ; Get the HWND of this script's main window.
OurId := WinExist("ahk_class AutoHotkey ahk_pid " ErrorLevel)
Loop %ScriptId%
if (ScriptId%A_Index% != OurId)
{ ; Close all other instances of this script.
WinClose, % "ahk_id " ScriptId%A_Index%
; Optionally wait to prevent multiple tray icons from showing.
WinWaitClose, % "ahk_id " ScriptId%A_Index%
}
DetectHiddenWindows, Off
; Show the icon now that this is the only instance of this script.
Menu, Tray, Icon
OnExit, Exiting
return
Exiting:
ToolTip, Exiting...
Sleep, 1000
ExitApp |
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|