Multiple execution of the same script

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
SandyDoss
Junior Coder
Posts: 40
Joined: Wed Sep 07, 2016 12:47 am

Multiple execution of the same script

Post by SandyDoss » Wed Aug 09, 2017 6:15 pm

Quick question: If I have a script that will open an application, and I need to have the script execute twice at the same time, will the use of window handles work even if I'm using image recognition to find things on a window?

I'm thinking the script will (loosely):
set WIN_USEHANDLE on
launch an application
GetActiveWindow
SetFocus

and from then on, anything happening in the script will happen within that window. Then, when I launch the script a second time, the handle for GetActiveWindow will be different, so the second instance of the script will deal with the second window.

It looks like the image recognition calls can use the Window title as the haystack - can it use the window handle?
Do I have to SetFocus before each command?
Do I need to size the windows so they don't overlap?
Do I sound crazy? :roll:

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

Re: Multiple execution of the same script

Post by Marcus Tettmar » Fri Aug 11, 2017 11:30 am

Not sure how the same macro could do the same thing twice at the same time. Perhaps you mean in succession, not at the same time.

Always setting focus is not always necessary but good practise - something could steal the focus. But often with image recognition you then click on the UI object and that would have the same effect. So as always it depends whether you really need a SetFocus or not but it would certainly do no harm.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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