Cannot Get WaitWindowOpen to work

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
RNIB
Macro Veteran
Posts: 195
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Cannot Get WaitWindowOpen to work

Post by RNIB » Mon Sep 02, 2024 2:16 pm

I know this should be simple but I just cannot get this to work.
I have an application which always changes the title of the window depending on what file is open in it. It always follows this convention:

Title - Dolphin Publisher - (Path to file)

e.g.

Spiders Web - Dolphin Publisher - (C:\Users\OJohnson\OneDrive - RNIB\Desktop\Mass Ingest With Links\700433\ncc.html)

The bit that's always constant is:
Dolphin Publisher

I just need the script to wait until this window is open before it proceeds.

I've tried:

WaitWindowOpen>Dolphin*
and
WaitWindowOpen>Publisher*

But it just sits there and does nothing. I thought that perhaps the window was appearing before the script had a chance to get to the WaitWindow Open so I tried:

Code: Select all

IfWindowOpen>Dolphin*
GoTo>Build
Else
WaitWindowOpen>Dolphin*
Endif
Label>Build
But that didn't work either and it just sits there.

With a file open in the program, Code Builder tells me that there are two windows open with the names:
Spiders Web - Dolphin Publisher - (C:\Users\OJohnson\OneDrive - RNIB\Desktop\Mass Ingest With Links\700433\ncc.html)
Publisher

I've tried using either of these with and without and asterix an nothing seems to make a difference. The only thing that works is if I enter the full windows name but this changes every time and I do not know what the title will be as that is generated by the content of the file that is open.

Any ideas?

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

Re: Cannot Get WaitWindowOpen to work

Post by JRL » Wed Sep 04, 2024 3:30 pm

Here is a possible replacement for the built in WaitWindowOpen> function. Depends on whether or not your window shows up using GetWindowList>. If you want to wait a long time or forever, enter a big number for the timeout.

Modify as needed.

Code: Select all

//GoSub>srtWaitWindowOpen,Criteria (Case Sensitive),Timeout (seconds)
GoSub>srtWaitWindowOpen,Dolphin Publisher,5

SRT>srtWaitWindowOpen
  Timer>vStartTime
  Let>OpenTestFlag=0
  While>OpenTestFlag=0
    Wait>0.01
    GetWindowList>vData
    Separate>vData,srtWaitWindowOpen_var_1,vOpenTestRes
    If>vOpenTestRes_Count>1
      Let>OpenTestFlag=1
    EndIf
    Timer>vNextTime
    If>{(%vNextTime%-%vStartTime%)>(%srtWaitWindowOpen_var_2%*1000)}
      Goto>labWaitWindowOpenTimedOut
    EndIf
  EndWhile
  Goto>labWaitWindowOpenComplete
  Label>labWaitWindowOpenTimedOut
    MDL>WaitWindowOpen "%srtWaitWindowOpen_var_1%" timed out%crlf%Goodbye...
    Exit>0
  Label>labWaitWindowOpenComplete
END>srtWaitWindowOpen

MDL>%srtWaitWindowOpen_var_1% found

RNIB
Macro Veteran
Posts: 195
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Re: Cannot Get WaitWindowOpen to work

Post by RNIB » Thu Sep 05, 2024 2:08 pm

That is brilliant!

It works perfectly. I've had problems with this particular application for years and every time they release a new version they do something that changes the window name in some way and I have to go back and amend all the macros. This solves all of that.

Thank you so much, you saved me so much work and stress. :mrgreen: :mrgreen: :mrgreen:

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

Re: Cannot Get WaitWindowOpen to work

Post by JRL » Thu Sep 05, 2024 2:26 pm

:D

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