Macro stalls after ClickTag presents popup screen

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
dafe
Junior Coder
Posts: 23
Joined: Sun Apr 06, 2008 4:21 am

Macro stalls after ClickTag presents popup screen

Post by dafe » Sun Apr 06, 2008 4:45 am

I've just started using Macro Scheduler for screen scraping purposes. I've created my WebRecorder Macro and have imported it into MacroScheduler.

My problem is right towards the end of the script where i click a button to cancel the order which is currently open. A popup dialog box is presented once i do this (verifying that i wish to cancel the order). As soon as this popup box arrives, the macro no longer continues, the popup doesn't accept the macro commands and only user interaction clears it. Once cleared the macro continues to run.

The popup forces focus even if you attempt clicking out of the box, so it shouldn't be a focus issue (i've tried setting focus all the same, you should see it commented out in the below code)

This issue seems very similar to the one found at this thread
http://www.mjtnet.com/usergroup/viewtop ... n&start=15
but i'm unable to figure out a workaround in my particular instance

At this stage i'm that new to MacroScheduler that it could be a very basic problem, so apologies if it should be an easily found answer, but it has had me scratching my head for quite some time now.

Any help or pointers would be greatly appreciated.

script code below

Code: Select all

// Generated by MacroScript WebRecorder 2.01
// Recorded on Saturday, April 5, 2008, at 10:39 PM

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

IE_Navigate>%IE[0]%,https://********,r
Wait>delay
GetActiveWindow>window_title
If>{(%window_title% = "Utility Key")}
	Send Character/Text>****
	Press Enter
Endif

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

Let>FrameName={""}
Let>FormName={""}
Let>TagValue={"Order Now"}
IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,A,TEXT,str:TagValue,r

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

Let>k=1
ReadLn>c:\data.csv,k,line
If>line=##EOF##,finish

Label>start
Let>FrameName={""}
Let>FormName={"form"}
Let>FieldName={"ITPInputText_existingOrder"}
Let>FieldValue={"0%line%"}
Let>k=k+1
IE_FormFill>%IE[0]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,0,r
Wait>delay

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

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

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

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

Let>FrameName={""}
Let>FormName={"form"}
Let>TagValue={"https://***************/cancel.gif"}
IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,INPUT,SRC,str:TagValue,r
Press Enter
//Below is where i've tested SetFocus
//WaitWindowOpen>Windows Internet Explorer
//SetFocus>Windows Internet Explorer
//Wait>1
//Press Enter

//Goto>start

Label>end_script
Last edited by dafe on Tue Apr 08, 2008 12:19 am, edited 1 time in total.
--

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

Post by Marcus Tettmar » Mon Apr 07, 2008 7:38 pm

Where is the macro stalling? Is it after that last ClickTag? I wonder why that Press Enter is there, and whether that could be causing the problem. If you put the following immediately after the ClickTag line do you see the message box?

MessageModal>I am here

And have you tried stepping through with the debugger? Or enabling logging to see what the log file shows?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

dafe
Junior Coder
Posts: 23
Joined: Sun Apr 06, 2008 4:21 am

Post by dafe » Tue Apr 08, 2008 1:49 am

I placed that 'Press Enter' after the clicktag just as a test. The 'OK' button is selected by default, and the window forces focus.

I've replaced 'Press Enter' with your 'MessageModal>I am here' and have run and logged the macro.

The script progresses to the window popup as per usual, however the message box will only appear after i have manually selected a response for the popup.

The log for the macro is below. The script obviously never completed as i didn't make any manual choice for the popup. I've included the part relative to the the problem (i.e. the end of the script). I've logged start and completion of each step

Code: Select all

8/04/2008 11:25:58:312 - START: Let>FrameName={""}
8/04/2008 11:25:58:312 -   END: Let>FrameName={""}
8/04/2008 11:25:58:312 - START: Let>FormName={"form"}
8/04/2008 11:25:58:312 -   END: Let>FormName={"form"}
8/04/2008 11:25:58:312 - START: Let>TagValue={"https://****/cancel.gif"}
8/04/2008 11:25:58:312 -   END: Let>TagValue={"https://****/cancel.gif"}
8/04/2008 11:25:58:312 - START: IE_ClickTag>0,str:FrameName,str:FormName,INPUT,SRC,str:TagValue,r
log file *with* manual click below

Code: Select all

/04/2008 11:27:38:000 - START: Let>FrameName={""}
8/04/2008 11:27:38:000 -   END: Let>FrameName={""}
8/04/2008 11:27:38:000 - START: Let>FormName={"form"}
8/04/2008 11:27:38:000 -   END: Let>FormName={"form"}
8/04/2008 11:27:38:000 - START: Let>TagValue={"https://****/cancel.gif"}
8/04/2008 11:27:38:000 -   END: Let>TagValue={"https://****/cancel.gif"}
8/04/2008 11:27:38:000 - START: IE_ClickTag>0,str:FrameName,str:FormName,INPUT,SRC,str:TagValue,r
8/04/2008 11:32:31:703 -   END: IE_ClickTag>0,str:FrameName,str:FormName,INPUT,SRC,str:TagValue,r
8/04/2008 11:32:32:359 - START: MessageModal>I am here
8/04/2008 11:32:34:109 -   END: MessageModal>I am here
thank you for your 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 » Tue Apr 08, 2008 6:32 am

ClickTag must be causing the pop up to appear and waiting for IE to be ready, which it won't be until the pop up is manually cleared.

Either replace that ClickTag with keystrokes that click the button, e.g.:

Press Tab
Press Enter

Or, create another macro which clears the dialog. Set it up with a window event schedule so that this macro fires when the dialog appears.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

dafe
Junior Coder
Posts: 23
Joined: Sun Apr 06, 2008 4:21 am

Post by dafe » Wed Apr 09, 2008 2:56 am

tabbing to the link has worked. thank you very much.
the macro correctly clears the popup window now.

as i'm wanting to have this macro run on other machines, and possibly on varying versions of IE, is there someway to set a "relative" position to begin tabbing from?
--

User avatar
Djek
Pro Scripter
Posts: 148
Joined: Sat Feb 05, 2005 11:35 pm
Location: Holland
Contact:

Post by Djek » Wed Apr 09, 2008 5:57 pm

I use ctrl-tab in ie to go to "default tabposition"

hth
DJek

dafe
Junior Coder
Posts: 23
Joined: Sun Apr 06, 2008 4:21 am

Post by dafe » Sat Apr 12, 2008 9:19 am

ok, so unfortunately i'm unable to use keypresses as a different amount of tabs are required depending on the order which is being displayed, and i'm unsure if you can start tabbing from a relative position to get around this.

i've created a seperate macro called "CancelOrder" which is fired whenever the window is detected

Code: Select all

Label>start
GetActiveWindow>window_title,X,Y
If>{(%window_title% = "Windows Internet Explorer") AND (%X% = 335) AND (%Y% = 319)}
Wait>1
Press Enter
Endif
Wait>0.1
Goto>start
this works flawlessly if i navigate to the popup by myself, however it displays strange behaviour once i engage MS to navigate to the popup.
Essentially the browser either hangs as soon as it opens (displaying nothing but a whitescreen) or it will load the first page and stop there.

I can see that my CancelOrder script is being launched in the status bar of MS so it is definitely running, and i assume, is what is causing my first macro to stall.

I've also attempted changing my CancelOrder script to use OnEvent>WINDOW_OPEN to call a subroutine outside of the loop, with little success. I'm going to head back to this method for some more testing though.

Any suggestions?
--

dafe
Junior Coder
Posts: 23
Joined: Sun Apr 06, 2008 4:21 am

Post by dafe » Sat Apr 12, 2008 10:35 am

ok, so i went back to the drawing board and started my macro from scratch. I've rerecorded in web recorder and have continued from there.

My "CancelOrder" macro was active the whole time, and reliably closed the popup during the recording phase and subsequently kept closing it as i added bits to my main macro and gave it test runs.

however - as soon as i added the following line

Code: Select all

ReadLn>c:\data.csv,k,line
the "CancelOrder" macro no longer closed the popup window.

Is there any reason why the above line would cause my "CancelOrder" macro to stop closing the popup window??

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