Determine if a Compiled Script is running

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Determine if a Compiled Script is running

Post by kpassaur » Mon Jan 15, 2007 4:57 pm

The goal is to create an opening menu that would display a button to turn on a compiled macro if it is off and off if it is on.

This macro would be monitoring a folder and have no windows. (Therefore WaitWindowOpen would be out)

I thought of just creating a text file when it is turned on and checking to see if it exists (deleting it when the utility is turned off); however, if the computer shuts down unexpectedly the file would still be there with no way to turn it back on.

So, I need a way to see if an application is running. I thought of GetWindowProcess but again there is no Window Name just an application name

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Jan 15, 2007 5:14 pm

Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Re: Determine if a Compiled Script is running

Post by jpuziano » Mon Jan 15, 2007 5:42 pm

kpassaur wrote:however, if the computer shuts down unexpectedly the file would still be there with no way to turn it back on.

So, I need a way to see if an application is running. I thought of GetWindowProcess but again there is no Window Name just an application name
This situation is similar to the previous post.

To avoid this problem, you could add a dialog to your compiled macro and give it a unique window title. Then you could check for the existance of that window from the Main script and offer the appropriate button to either turn on or turn off the process.

The dialog could be very simple, it could just display a message "process xyz running". You could add a button to the dialog to offer to turn off the process if you want. If you don't want the user to be able to change the dialog directly, you could remove all controls or even make the dialog window invisible.

Even if invisible, the IfWindowOpen> command would still be able to detect it and you would know if the process (compiled macro) is running or not.

Marcus, what is the code required to make a dialog "invisible"?
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Jan 15, 2007 6:51 pm

What I've always done to make a dialog (or any other window) "invisible" is move it to a location far from view. Something like this is usually adequate

MoveWindow>Window Name,-10000,-10000

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Jan 15, 2007 8:54 pm

Keith,

If you haven't resolved this yet, here is a script with a dialog containing a single button that will toggle notepad on and off. The "flag" is the name of the button so there is no external settings, files, etc. to be concerned about. As the application being started and stopped toggles, so does the button name. By testing the button name we can know the state of the application. Any application or executable could be substituted for “Notepadâ€Â

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Mon Jan 15, 2007 9:36 pm

Thanks for the above script JRL... a great addition to the snippet collection. :)
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Wed Jan 17, 2007 8:08 am

JRL wrote:What I've always done to make a dialog (or any other window) "invisible" is move it to a location far from view. Something like this is usually adequate

MoveWindow>Window Name,-10000,-10000
Thanks JRL, that should work. However, if anyone wants to try hiding or unhiding windows, there's more info here: Is it Possible to Unhide a Hidden Window? In that post, there is the following...
mtettmar wrote:We do intend to add a function to IEAuto.DLL to HIDE the IE window altogether. IE offers a property to make it visible or not, so we can easily expose that method and hide it.
That would certainly be useful... any news on that Marcus?
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Jan 18, 2007 4:33 pm

jpuziano wrote:
mtettmar wrote:We do intend to add a function to IEAuto.DLL to HIDE the IE window altogether. IE offers a property to make it visible or not, so we can easily expose that method and hide it.
That would certainly be useful... any news on that Marcus?
That was added ages ago. Note the ShowIE function.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Thu Jan 18, 2007 4:45 pm

mtettmar wrote:That was added ages ago. Note the ShowIE function.
Thanks Marcus! :)
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts