Showing results for 
Show  only  | Search instead for 
Did you mean: 

Sample usage of Whenever for Proxy Login



I have a weird proxy configuration that makes the proxy login screem appear at any point during script execution.

I am trying to use whenever method but did not quite get on how to use it.

Basically I have the actions the user need to take to fill the authentication screen and would like to play those, anytime the screen appears.

Can someone help me with that?




@Igor S.

Hi Igor,

The documentation page that describes Whenever contains two pretty good examples, so I do not
think you should have problems with this method.I’d guess that your real problem is with
choosing the event that needs to be referenced by Whenever.

The Recorder allows for several types of events.
Both documentation examples on using
Whenever use Key events, not applicable to your use case. You need an event that would be triggered
when a proxy login window pops up, but would not be triggered in any other circumstances. If the proxy login window can be unambiguously
represented by IEWindow or Window object, then a WindowEvent should be sufficient. Otherwise, you will need to use either a BitmapEvent, that would rely on a graphical image unique for the a proxy login
window, or a ScreenEvent that would rely on a text unique for the a proxy login window.

Whatever kind of even you choose, it might be pre-created
and stored in the Recorder database or created dynamically. In case the event can always be the same on
every execution of the script, the former method is much easier to use.

Thank you,



Thanks a lot for your help. My doubt is about this piece of code:

  ret = Whenever("F9 Key Event")       

If ret = True Then
MsgBox "F9 Key Event is active"
' Keep the whenever active.
MsgBox "F9 Key Event could not be activated"
End If

Would this IF clause be executed whenever the PopUp appears? I've made some tests and when the Window did not appear the script would hang. Right now I have the following code:

proxy = Whenever("Portal-PopUp-Proxy")

If proxy = True Then
ShowStatusBox("Proxy popup presented")
End If

At the end I have the script_whenever Sub created with the code to fill the window.

I have just double checked and my event is configured to check if the window Exists.(the window is unique).

However when the script start it hangs showing the message "Proxy popup presented". Am I doing something wrong?

Thanks a lot for your help,


@Igor S.

Hi Igor.

Your proxy variable gets a value True if whenever has been
successfully activated, but not as an indication that pop-up is presented. So, the code in your second code snippet
should be executed only once during the script execution. Hope this is the case in your script. The message in the ShowStatusBox statement, though, should end with "activated" rather than "presented".

What is definitely wrong in your script is using SuspendScript. If you check SuspendScript
documentation, it starts with the words “Suspends the test
script being played back”. While this is
appropriate for the Key event (script is awaiting the key pressing), it should not be present in the code in your case. You want the
script to continue running, and only in case the event gets triggered (which
might not happen at all) pass the control to Sub
. Likewise,
Sub Script_Whenever should
not contain ResumeScript – once Sub
is finished, the
script execution will resume from the statement that would be executed if
control would not be passed to Script_Whenever.

Hope this helps.

Thank you,


Thanks a lot for the detailed explanation.

I now understand what I have to do.

I'll fix my script.