Problem with dialogs

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
s.newave
Newbie
Posts: 2
Joined: Sat Aug 05, 2006 12:54 am

Problem with dialogs

Post by s.newave » Tue Aug 08, 2006 6:02 am

Hi,

The vpn software i use to access my work automatically disconnects every 30mins or so and i am trying to create a script that automatically logs back in when the vpn disconnects.

When it disconnects it pops up 2 dialog boxes at the same time with the same window title called Contivity VPN Client. The active one asks you if you want to login and if you press yes the top one disappears leaving the other dialog where you enter your password and hit enter to login. Seeing as they both have the same window title i am using the dialog height to differentiate them.

The problem im having is that it seems that when the dialogs popup they seem to lose focus immediately which causes the macro not to run. I am triggering this macro using the "Run macro when this window exists" option (incidentally whenever i uncheck "Only when visible" click ok then click advanced options again that option seems to be re-checking itself which is probably causing problems). This leads to the dialog sitting in the background somewhere and even if i click on it the macro doesnt run as i assume it only runs through once until a new dialog with that name exists? To try and correct this i am using a repeat loop which should keep looping until all dialogs with that name no longer exist and i am logged back in. This is prolly the ugliest way to do this and it doesnt even work lol:

Let>done=1

Repeat>done

IfWindowOpen>Contivity VPN Client
SetFocus>Contivity VPN Client
Wait>1
GetActiveWindow>CurrentWindow,X,Y,Width,Height

IF>Height=115
Press ALT
Send Character/Text>y
Release ALT
Press Enter
done=1
ENDIF

IF>Height=357
Press ALT
Send Character/Text>p
Release ALT
Send Character/Text>passwd
Press Enter
done=1
ENDIF

ENDIF

IfWindowOpen>Contivity VPN Client
done=0
ENDIF

Until>done=1

Any ideas?

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

Post by Marcus Tettmar » Tue Aug 08, 2006 7:59 am

done=1 should be:

Let>done=1

Otherwise done will never be 1.

Another approach is to identify the window based on text within it rather than on the window title. I demonstrated that approach with this Adobe Reader Install script:

http://www.mjtnet.com/forum/viewtopic.php?t=3034
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