Great product and a great forum. Normally I can find the answers by searching the forum but this time I have been unsuccessfull.
How can I prevent a user from accidently running a compiled macro multiple times by clicking on an exe more than once?
Allow only one instance of compiled script
Moderators: Dorian (MJT support), JRL
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Here are two methods ......
1. First line of macro could rename itself.
Last line of macro could rename itself back to normal.
OR
2. First line checks for a temp file exists or for an INI value. Quit or Run based on results.
Second line creates a temp file or writes a value to an INI file.
Do Stuff
Last line deletes the temp file or changes the INI value.
1. First line of macro could rename itself.
Last line of macro could rename itself back to normal.
OR
2. First line checks for a temp file exists or for an INI value. Quit or Run based on results.
Second line creates a temp file or writes a value to an INI file.
Do Stuff
Last line deletes the temp file or changes the INI value.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
I would use a registry key. Otherwise you need to know which path to store the INI file in and if there are multiple copies of the exe in different locations this could be an issue. But all copies could access same registry key:
Now only one copy of the exe can actually do anything at a time.
Code: Select all
RegistryReadKey>HKEY_CURRENT_USER,Software\MyEXE,Running,isRunning
If>isRunning<>TRUE
HKEY_CURRENT_USER,Software\MyEXE,Running,TRUE
..
.. rest of your macro code here
..
RegistryWriteKey>HKEY_CURRENT_USER,Software\MyEXE,Running,FALSE
Endif
Last edited by Marcus Tettmar on Fri Jan 12, 2007 2:36 pm, edited 2 times in total.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
I meant TRUE. Have edited accordingly.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
There is a potential weakness of using a registry key for this:
- - user fires up macro
- macro updates registry to store value to denote "macro is running"
- power failure happens or user shuts off power to PC so there is no chance for the macro to change the registry value
- later, PC is powered up, user runs macro, macro checks registry, value indicates "macro is running" (even though it isn't) and macro shuts down... user can no longer run the macro.
Thanks for posting that Rain and take care all...Rain wrote:Another solution would be to add IfWindowOpen>Compiled Macros Dialog name,exit at the beginning of the script. That will shut the 2nd instant down immediately.
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 -
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 -