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!
SetFocus & WebRecorder (IE) Functions/Routines
Moderators: JRL, Dorian (MJT support)
-
- Newbie
- Posts: 2
- Joined: Tue Jul 14, 2009 12:39 am
- Location: Palos Verdes, California
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.
Another more straight forward way is to use the GetWindowHandle> function.
Hope this is helpful.
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
Code: Select all
GetWindowHandle>Internet Explorer*,handle
MDL>handle
-
- Newbie
- Posts: 2
- Joined: Tue Jul 14, 2009 12:39 am
- Location: Palos Verdes, California
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!
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!