Closing modal if present without waiting for full WW_TIMEOUT

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Warren
Pro Scripter
Posts: 83
Joined: Sun Oct 08, 2017 11:57 pm

Closing modal if present without waiting for full WW_TIMEOUT

Post by Warren » Mon Oct 09, 2017 10:17 pm

I want script to close now if it's already open, or if it's not, close it as soon as it opens with a maximum wait of WW_TIMEOUT.

That's what I thought WaitWindowOpen command did, but what's been happening instead is that if window was already open before command, it waits entire length of WW_TIMEOUT before closing it. I found a way around this with:

Code: Select all

IfWindowOpen>pageName
   CloseWindow>pageName
ELSE
   WaitWindowOpen>pageName
   IfWindowOpen>pageName
      CloseWindow>pageName
   EndIf
EndIf
But it seems quite kludgey, so I'd like to know if I'm missing something. Just basically want to open it now or as soon as it opens up until the timeout.


Also, this brings up a related issue:

Is there a way to keep the global WW_TIMEOUT value, but change it just for this window opening so it reverts back next time around? I thought I had stumbled across that the other day, but not seeing it now that I'm looking.

Again, I can come up with a solution, but again, it's kludgey:

Code: Select all

Let>defaultPageWait=60
Let>WW_TIMEOUT=defaultPageWait

SRT>closePage
   Let>WW_TIMEOUT=%closePage_var_2%
   IfWindowOpen>%closePage_var_1%
      CloseWindow>%closePage_var_1%
   ELSE
      WaitWindowOpen>%closePage_var_1%
      IfWindowOpen>%closePage_var_1%
         CloseWindow>
      EndIf
   EndIf
   Let>WW_TIMEOUT=defaultPageWait
END>closePage

GoSub>closePage,pageName,10
thx

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

Re: Closing modal if present without waiting for full WW_TIM

Post by Marcus Tettmar » Tue Oct 10, 2017 10:23 am

Struggling to understand your first issue. If the window is already open when you call WaitWindowOpen then it will not have to wait as it is already open. It will NOT wait for the timeout period. If your command is waiting for the timeout period then it can't be seeing the window and there's a mismatch with the title. All you should need is:

WaitWindowOpen>title
CloseWindow>title

Once it's open there's no need to see if it is open with IfWindowOpen since it must now be open. The above two lines do the same as both parts of your If/Else/Endif routine.

Re your second question re WW_TIMEOUT. Sure. You could just create your own variable to store your global value.

Code: Select all

Let>GLOBAL_WW_TIMEOUT=500
Let>WW_TIMEOUT=GLOBAL_WW_TIMEOUT

bla bla

//temporarily use a different value
Let>WW_TIMEOUT=100
//do whatever
//set it back
Let>WW_TIMEOUT=GLOBAL_WW_TIMEOUT
Alternatively you could set it and set it back:

Code: Select all

Let>REMEMBER_WW_TIMEOUT=WW_TIMEOUT
Let>WW_TIMEOUT=2000
//do something
Let>WW_TIMEOUT=REMEMVER_WW_TIMEOUT
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

Warren
Pro Scripter
Posts: 83
Joined: Sun Oct 08, 2017 11:57 pm

Re: Closing modal if present without waiting for full WW_TIM

Post by Warren » Tue Oct 10, 2017 1:26 pm

Ok,thx. Your description is back to how I thought it would work, so there must be some other issue causing it to wait the full timeout term before closing when just using stock command.

I'll try it with some other windows, and such until I can narrow down what's causing it to wait.

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