Script will not Recognise Window

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

jeffreymen
Newbie
Posts: 8
Joined: Wed Jun 04, 2008 4:05 am

Script will not Recognise Window

Post by jeffreymen » Wed Jun 04, 2008 4:23 am

I am trying to write a script to log into my bank account and export the transactions to a CSV file. This is how the Banks Site Works.

When you have selected the range of transactions that you want to export, you select an output format and then press ENTER. The site then pops up a "File Download" Dialog/Window and lets you enter a Filename. You press enter and the File is saved.

I recorded the script using WebRecorder and it all looked good, producing the following extract of code :-

------------------------------------------------------------------------------------

WaitWindowOpen>File Download
SetFocus>File Download

//FILE DOWNLOAD - YOU MAY NEED TO MODIFY THIS PART
//MODIFY FILE PATH AND NAME HERE:
Let>filename="C:\MickeyTheChips"
Wait>1
sSend>s
WaitWindowOpen>Save As
SetFocus>Save As
"Send>filename
Press Enter
WaitWindowClosed>Save As

-------------------------------------------------------------------------------------

The problem is that when I run it through the debugger, it gets stuck at "WaitWindowOpen>File Download" and never goes any further.

Thanks for any ideas ?

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Wed Jun 04, 2008 10:04 pm

Add an asterisk (*) after File Download.
Like this:

Code: Select all

WaitWindowOpen>File Download*

jeffreymen
Newbie
Posts: 8
Joined: Wed Jun 04, 2008 4:05 am

Post by jeffreymen » Thu Jun 05, 2008 12:05 am

Thanks very much for your reply, but unfortunately that did not work.

It almost seems that because the "File Download" screen does not appear visibly on the screen when the script is run as opposed to being recorded, the the Script cannot see it.

I even used GetActiveWindow just before the WaitWindowOpen and it came back with No Active Window. Below is an image of the window exactly as it appears when recording :-

Image

Once again thanks for your reply.

edauthier
Pro Scripter
Posts: 84
Joined: Sun Apr 13, 2003 1:26 pm
Location: USA

Post by edauthier » Thu Jun 05, 2008 2:21 am

First glance.. couple of typo's in your code:

Code: Select all


sSend>s 

"Send>filename

Remove s and " from your SEND>

jeffreymen
Newbie
Posts: 8
Joined: Wed Jun 04, 2008 4:05 am

Post by jeffreymen » Thu Jun 05, 2008 2:23 am

Script does not get to that point yet, but thanks for spotting that.

edauthier
Pro Scripter
Posts: 84
Joined: Sun Apr 13, 2003 1:26 pm
Location: USA

Post by edauthier » Thu Jun 05, 2008 2:28 am

Shorten code to: WWO>File*
Post back..

jeffreymen
Newbie
Posts: 8
Joined: Wed Jun 04, 2008 4:05 am

Post by jeffreymen » Thu Jun 05, 2008 2:39 am

Fantastic, that worked, but now when I get down to the Send>s, it actually sends the s to the debugger, hence the reason it now says sSend>s. It then hangs on the WWO>Save* waiting for the "Save Filename As" Window to appear.

//WaitWindowOpen>File Download*
WWO>File*
SetFocus>File*

//FILE DOWNLOAD - YOU MAY NEED TO MODIFY THIS PART
//MODIFY FILE PATH AND NAME HERE:
Let>filename=download.file
Wait>1
sSend>s
WWO>Save*
SetFocus>Save*
Send>filename
Press Enter
WWC>Save*
WWO>%filename%*
WWC>%filename%*

edauthier
Pro Scripter
Posts: 84
Joined: Sun Apr 13, 2003 1:26 pm
Location: USA

Post by edauthier » Thu Jun 05, 2008 2:59 am

Is the Save As window actually appearing on screen?

jeffreymen
Newbie
Posts: 8
Joined: Wed Jun 04, 2008 4:05 am

Post by jeffreymen » Thu Jun 05, 2008 3:03 am

No it isn't. It does not show any windows, just stays on the debugger Window and moves from Line to Line. Not even IE appears. Forgive my ignorance as I am new to this, is it supposed to ?

edauthier
Pro Scripter
Posts: 84
Joined: Sun Apr 13, 2003 1:26 pm
Location: USA

Post by edauthier » Thu Jun 05, 2008 3:13 am

So if you are getting past the File Download piece... it's going to be the SEND>S
you need to get the 's' out of the sSend>

Can you post your actual script and not the debug? The sSend> would appear when running in Debug/Trace, but your actual code cannot contain that s.

I think if you remove the s, the SEND>s will work and your script will continue to the Save As window..

jeffreymen
Newbie
Posts: 8
Joined: Wed Jun 04, 2008 4:05 am

Post by jeffreymen » Thu Jun 05, 2008 3:45 am

This is the actual code :-

Code: Select all

// Generated by MacroScript WebRecorder 2.03
// Recorded on  Wednesday, June 4, 2008, at 03:26 PM

//Move the mouse cursor out of harm's way to avoid causing mouseover events to interrupt
MouseMove>0,0
Let>delay=1
IE_Create>0,IE[8]

IE_Navigate>%IE[8]%,www.netbank.com.au,r
IE_Wait>%IE[8]%,r
Wait>delay

Let>FrameName={""}
Let>FormName={"LOGINForm"}
Let>FieldName={"USER_LOGON_NAME"}
Let>FieldValue={""}
IE_FormFill>%IE[8]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,0,r

Let>FrameName={""}
Let>FormName={"LOGINForm"}
Let>FieldName={"PASSWORD"}
Let>FieldValue={""}
IE_FormFill>%IE[8]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,0,r

Let>FrameName={""}
Let>FormName={"LOGINForm"}
Let>TagValue={"login"}
IE_ClickTag>%IE[8]%,str:FrameName,str:FormName,INPUT,NAME,str:TagValue,r

IE_Wait>%IE[8]%,r
Wait>delay

Let>FrameName={""}
Let>FormName={"LOGINForm"}
Let>TagValue={"export transactions"}
IE_ClickTag>%IE[8]%,str:FrameName,str:FormName,A,TEXT,str:TagValue,r

IE_Wait>%IE[8]%,r
Wait>delay

Let>FrameName={""}
Let>FormName={"SearchForm"}
Let>FieldName={"ACCOUNT_MOVEMENT_CRITERIA_PO"}
Let>FieldValue={"Mortgage Variable"}
IE_FormFill>%IE[8]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,0,r

Let>FrameName={""}
Let>FormName={"SearchForm"}
Let>TagValue={"statemachineEventName"}
IE_ClickTag>%IE[8]%,str:FrameName,str:FormName,INPUT,NAME,str:TagValue,r

IE_Wait>%IE[8]%,r
Wait>delay

Let>FrameName={""}
Let>FormName={""}
Let>FieldName={"METHOD_OF_EXPORT"}
Let>FieldValue={"CSV"}
IE_FormFill>%IE[8]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,0,r

Let>FrameName={""}
Let>FormName={""}
Let>TagValue={"statemachineEventName"}
IE_ClickTag>%IE[8]%,str:FrameName,str:FormName,INPUT,NAME,str:TagValue,r

IE_Wait>%IE[8]%,r
Wait>delay

//WaitWindowOpen>File Download*
WWO>File*
SetFocus>File*

//FILE DOWNLOAD - YOU MAY NEED TO MODIFY THIS PART
//MODIFY FILE PATH AND NAME HERE:
Let>filename=download.file
Wait>1
Send>s
WWO>Save*
SetFocus>Save*
Send>filename
Press Enter
WWC>Save*
WWO>%filename%*
WWC>%filename%*

Let>FrameName={""}
Let>FormName={""}
Let>TagValue={"https://www3.netbank.commbank.com.au/netbank/images/button_exit.gif"}
IE_ClickTag>%IE[8]%,str:FrameName,str:FormName,IMG,HREF,str:TagValue,r

IE_Wait>%IE[8]%,r
Wait>delay

IE_Wait>%IE[8]%,r
Wait>delay

Let>FrameName={""}
Let>FormName={""}
Let>TagValue={"https://www3.netbank.commbank.com.au/netbank/images/but_close.gif"}
IE_ClickTag>%IE[8]%,str:FrameName,str:FormName,IMG,HREF,str:TagValue,r

Label>end_script
Thanks for continued help.

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

Post by Marcus Tettmar » Thu Jun 05, 2008 6:07 am

Replace the Send>s with:

Press ALT
Send>s
Release ALT

s is the shortcut key for the Send button, so it needs to be sent with the ALT key.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

jeffreymen
Newbie
Posts: 8
Joined: Wed Jun 04, 2008 4:05 am

Post by jeffreymen » Thu Jun 05, 2008 6:20 am

No luck I'm afraid, putting that in opened the Search Drop down in the actual Debugger Window. It thought I wanted to do an ALT-S in the Debugger Window. Code Below :-

Code: Select all

IE_Wait>%IE[8]%,r
Wait>delay

//WaitWindowOpen>File Download*
WWO>File*
SetFocus>File*

//FILE DOWNLOAD - YOU MAY NEED TO MODIFY THIS PART
//MODIFY FILE PATH AND NAME HERE:
Let>filename=download.file
Wait>1
Press ALT
Send>s
Release ALT
WWO>Save*
SetFocus>Save*
Send>filename
Press Enter
WWC>Save*
WWO>%filename%*
WWC>%filename%*
I think this software just doesn't cater for this type of Window that opens in Websites. Thanks for all your help. Much appreciated, but I won't waste your time any further.

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

Post by Marcus Tettmar » Thu Jun 05, 2008 7:15 am

jeffreymen wrote:No luck I'm afraid, putting that in opened the Search Drop down in the actual Debugger Window. It thought I wanted to do an ALT-S in the Debugger Window. Code Below :-
That's because the debugger is the active window. But if you have Refocus Windows checked in the debug menu and the script had previously focused a different window it should remember that and refocus that window before issuing the ALT-S. However, it can be difficult to debug actions like this that depend on focus, for hopefully obvious reasons. That's why for these sections of code I'd use breakpoints and run to breakpoint, rather step each line.
I think this software just doesn't cater for this type of Window that opens in Websites. Thanks for all your help. Much appreciated, but I won't waste your time any further.
I'm sorry you think that. In fact I have no trouble automating windows like this and in fact Macro Scheduler has, over the last 11 years, been used to automate almost every type of windows imaginable.

I would debug your script but I can't do that fully because it requires a log in. However, I started a file download from a different website (our own actually) and then ran the pertinent section of code. The following code worked well for me:

Code: Select all

//WaitWindowOpen>File Download*
WWO>File Download*
SetFocus>File Download*

//FILE DOWNLOAD - YOU MAY NEED TO MODIFY THIS PART
//MODIFY FILE PATH AND NAME HERE:
Let>filename=download.file
Wait>1

Press ALT
Send>s
Release ALT

WWO>Save As
SetFocus>Save As
Send>filename
Press Enter
WWC>Save As
WWO>%filename%*
WWC>%filename%*
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

jeffreymen
Newbie
Posts: 8
Joined: Wed Jun 04, 2008 4:05 am

Post by jeffreymen » Fri Jun 06, 2008 12:13 am

Thanks for your reply. I must say I am extremely impressed at the level of support you offer.

I did have refocus Windows checked and I made sure in recording that the other window did have focus. I do understand about the difficulty of running Focus based Scripts in a debugger.

I am very impressed with the way the product makes things quite simple and am disappointed that I have not been able to get this to work.

I think the problem is that the Save As Dialog appears directly after the Download File Dialog, a problem I am having with another piece of scripting software (iMacros) we are evaluating for our company.

Once again thanks for your help in this matter.

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