I am writing a script to keep a Citrix session alive while using an app that only exposes it's UI as an Explorer add-in. This app is run as a seamless window to the client. The problem is that Citrix/MS ignores the explorer.exe process and will log the user out after 30 minuntes if only an explorer process is running. So, here comes an Autoit script to the rescue. My Script launches the explorer window and then stays open as long as it sees a visible window that has explorer.exe as it's process. The script works flawlessly thus far and stays open until the last explorer window is closed in that particular session, until I add a check to see if it is already running. There is no use in having more than one of the processes running per session. Unfortunately checking for the process itself is problematic because the built-in "ProcessList" and "ProcessExists" functions won't limit themselves the just that user session, they look at the whole server, that could have up to 14 other users running the exact same script on it and using WMI to check the ownership of the process is really slow. So I decided to create a hidden window as part of this script called RunningDocsLauncher. Then at the beginning of the script I do a "If Not WinExists("RunningDocsLauncher") then". Here is where I have a problem. If the eDocs window does not exist, but the back-end processes are running, the script launches the explorer window and then exits (it should stay in memory at this point). If I launch it a second time, it launches a second explorer window and then stays in memory and all subsequent launches run an additional explorer window and then properly exit. If I remove the WinExists condition and the requisite EndIf, the first launch stays in memory, but then all subsequent launches stay in memory as well. Any ideas as to why adding the WinExists causes the first launch to exit instead of staying in memory?
#include <Process.au3> ;Launch explorer with a new window pointing at the eDocs node ;Check to see if the hidden window does not exist, continue if it does not exist ;Create the hidden window ;Wait 60 seconds for the "eDocs" window to appear ;Check to see if a window is visible that is created by explorer.exe Else ;if the eDocs window does not appear, check for the logon window and wait for it to close (Docs Supervisors must login to the system) Return 1 Return 0 $ExplorerRunning = 0 $ExplorerRunning = 1 Return $ExplorerRunning