SetFocus & WebRecorder (IE) Functions/Routines

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
David_PVMC
Newbie
Posts: 2
Joined: Tue Jul 14, 2009 12:39 am
Location: Palos Verdes, California

SetFocus & WebRecorder (IE) Functions/Routines

Post by David_PVMC » Tue Jul 14, 2009 1:01 am

I have a couple of questions regarding the SetFocus command.

I've written a few macros that jump between Internet Explorer and Microsoft Excel. Within a webpage I "IE_ClickTag" a button to download data to a tab delimited file... then I jump to Excel and import. When I jump back, I've had difficulty "gaining control" of Internet Explorer with what I would expect would work...

WaitWindowOpen>IEWindowname*
SetFocus>IEWindowname*
Wait>delayinseconds
...continue with my IE commands in the Macro...

I've temporarily solved this problem by inserting four additional lines that then allow me to continue with my IE commands, but only after these lines have executed...

IE_Back>%IE[0]%,r
Wait>delay
IE_Forward>%IE[0]%,r
Wait>delay

Obviously, this is not a very "elegant" solution, but it's the only way I've gotten the rest of my code to execute. Any other solutions come to mind?

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

I have another related question, which is... is there a way to join an Internet Explorer "session" already in progress prior to the start of running my macro?

Right now, the only way I can get "a handle" to an Internet Explorer session to to issue the command...

IE_Create>0,IE[0]

... which basically creates a new webbrowser page and assigns/gets a "handle" to it and stores that handle in the variable IE[0]. How can I get a "handle" to an already running webpage?

To debug my program, right now I need to go through a lengthy logon process and "click" through a number of pages to get to my "data". I'd much rather logon myself before starting the Macro, and then have the macro commands focus on the data retrieval task. That would also allow me to keep sensitive account and password information out of my macro.

Thanks for you help!

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Jul 14, 2009 2:40 am

I have no suggestions for the first part of your question except to say that if it works and it works all the time, I'd be inclined to use what you have.

For your second question about getting a window handle. Macro Scheduler provides a couple of easy ways to get a window handle. One way is to focus the window whose handle you want then set the system variable "WIN_USEHANDLE" to 1. After that use the GetActiveWindow function.

Code: Select all

SetFocus>Internet Explorer*
Let>WIN_USEHANDLE=1
GetActiveWindow>Handle,xpos,ypos
Let>WIN_USEHANDLE=0

MDL>handle
Another more straight forward way is to use the GetWindowHandle> function.

Code: Select all

GetWindowHandle>Internet Explorer*,handle
MDL>handle
Hope this is helpful.

David_PVMC
Newbie
Posts: 2
Joined: Tue Jul 14, 2009 12:39 am
Location: Palos Verdes, California

Post by David_PVMC » Tue Jul 14, 2009 11:24 pm

JRL,

Thanks! Very helpful. I have the "mjtnet MACRO SCHEDULER Version 11.0 manual," so I quickly found the reference to the "GetActiveWindow" function and other related functions (p. 132). I'm kicking myself for not finding it there first... anyway, thanks you and perhaps if I use handles instead of window names it might solve the first problem I listed. Much appreciated!

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