Why WaitWindowFocused?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Why WaitWindowFocused?

Post by armsys » Wed Mar 19, 2014 1:13 am

What's the difference between WaitWindowFocused and WaitWindowOpen + SetFocus?
I notice that WaitWindowFocused does not function like SetFocus.

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

Post by JRL » Wed Mar 19, 2014 2:40 am

That was my request so I suppose it should be up to me to explain :wink:

I often have a window already open but I'm waiting for a process to complete before that window is available for more user-like activity. I think that WaitWindowFocused will help solve that situation.

Read the original request here.

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Wed Mar 19, 2014 3:15 am

Thanks for identifying yourself as the inventor of the newly born function.
The online help defeats normal users' understanding, including myself.
Your original post helps unmask the mystery.
It turns out that the WaitWindowFocused was conceived based upon several assumptions:
1. The window in question is already active in the background.
2. The window in question is currently busy.
3. The window in question is not yet a foreground window.
4. The window in quesiton will become a foreground window after completing its current task.

No wonder WaitWindowFocused is not related to WaitWindowOpen and SetFocus.

JRL, thanks for your help.

Code: Select all

Label>WaitForUpdatingWO
GetActiveWindow>WinTitle,WinX,WinY
Separate>WinTitle,Updating WO:,WaitUWOres
If>WaitUWOres_Count>1
Else
  Wait>0.5
  Goto>WaitForUpdatingWO
EndIf

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

Post by Marcus Tettmar » Wed Mar 19, 2014 7:04 am

Armsys,

The help file is accurate. It doesn't know or care if the window is busy and the window doesn't have to be in the background.

It simply waits until the specified window both EXISTS and is FOCUSED. If the specified window exists and is the active window it will return.

The manual says:

"Waits for a specified window to open/appear and be focused (the foreground window). "

Is that really so confusing as to "defeat understanding"?

When opening a new window it will usually become the active window, so in that case, in most cases, WaitWindowOpen is enough. But what if the window in question may already exist and you want to wait until it is the active window? You want to know that it exists and is active. That's what WaitWindowFocused will do.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Wed Mar 19, 2014 7:31 am

Hi Marcus,
Marcus Tettmar wrote:The manual says:
"Waits for a specified window to open/appear and be focused (the foreground window). "
That's exactly the genesis of the confusion. In the absence of JRL's background tale, I would be impressed that WaitWindowFocus is a combination of: WaitWindowOpen + SetFocus.
After testing with scripts, I found the WaitWindowFocusd has neither functonality.
Actually, there's one BIG if: The windows (process) in question suddenly, mysteriously, automatically transits from background to foreground unaided by SetFocus.
Otherwise, WW_RESULT for WaitWindowFocused is always "FALSE".

Word rarely fits into the above scenario whereby WaitWindowFocused can yield a more desirable outcome.

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

Post by Marcus Tettmar » Wed Mar 19, 2014 7:40 am

Let me be totally candid and say that I find it hard to follow your form of English. So perhaps we just struggle to understand each other. I don't follow your last post, and I still think the way it has been explained in the help file is precise.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Wed Mar 19, 2014 7:50 am

Appreciate your candor. Anyway I fully understand your English perfectly.
>I still think the way it has been explained in the help file is precise.
Agree.
Thank for your amplified clarification.

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