Hi all,
Im trying to use the setFocus command, but it does not work oh the window I need it to. I have tested it using:
setFocus>Notepad*
setFocus>Inbox*
etc, with no problems. I have a program called "ResourceIQ" that I need to focus on. I have tried:
setFocus>ResourceIQ* (which is how it looks in the upperleft of the ResourceIQ window)
setFocus>Res*
setFocus>Re*
but nothing works. Any suggestions on how to either set the focus correctly or how to work around it?
Thanks in advance.
Basic Question: Can't focus on a specific window
Moderators: Dorian (MJT support), JRL
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Just curious when you say it doesn't work.
How do you know it does not work?
What are you looking for?
Focus can change and you may not see any difference.
Changing focus should make that window the active window.
What happens when you do this?
Open NotePad. Open WordPad. Now, run the following script:
How do you know it does not work?
What are you looking for?
Focus can change and you may not see any difference.
Changing focus should make that window the active window.
What happens when you do this?
Open NotePad. Open WordPad. Now, run the following script:
SetFocus>Untitled - Notepad*
GetActiveWindow>window_title,X,Y
MessageModal>Active Window is %window_title%. Should be Untitled - Notepad
SetFocus>Document - WordPad*
GetActiveWindow>window_title,X,Y
MessageModal>Active Window is %window_title%. Should be Document - WordPad
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
I opened both notepad and wordpad, cut and paste your script and got this message:
"Specified Window "Untitled -Notepad*" Not Present. Any Subsequent Key Sends In Script May Cause Exceptions."
I do have several scripts that succesfully run a "SetFocus" command, but for whatever reason, it does not like focusing on "Resource IQ*".
I don't know if this has anything to do with it - the .exe file is executed out of that program itself.
"Specified Window "Untitled -Notepad*" Not Present. Any Subsequent Key Sends In Script May Cause Exceptions."
I do have several scripts that succesfully run a "SetFocus" command, but for whatever reason, it does not like focusing on "Resource IQ*".
I don't know if this has anything to do with it - the .exe file is executed out of that program itself.
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Window not present
Usually, when I get that message, it means I have to insert some kind of wait between the execute file command and whatever I want done next.(Macsch keeps on going even if the window hasn't made it up yet, and the next command looks for its window- doesnt find it and thus the error messg) WaitReady>1 works. (You can get the hang time down by using wait> and paring the time down by trial until it's as fast as it'll go and still work, but you'd better be there to catch it if it chokes). I usually use a series. ExecuteFile>/WaitWindowOpen>/Wait>0.3/SetFocus>/.
Window Handle picks between identically titled windows
Here is a script which will give you the window handle of the very last window opened(in this case notepad). when the message appears you will see a number which is the window's handle. (To check this number,I don't use the "view system windows" from the editor page- it seems to freeze up occasionally, but rather from the main page under tools.) All this is in HELP under GetActiveWindow
If you hot key this(macroproperties/hot key)and then run it over and over, you'll see the window handle is changing for each new notepad window opened, even though EACH WINDOW TITLE IS EXACTLY THE SAME AS ALL THE OTHERS. The Maximize/Minimize moves are to convince me that that window is really the one being worked on. When the Message appears hit the spacebar, or the letter o, or the enter key to continue.
Let>WIN_USEHANDLE=1
Let>MSGSTAYONTOP=1
ExecuteFile>C:\WINDOWS\notepad.exe
WaitReady>1
Wait>0.5
GetActiveWindow>window_title,X,Y
Let>justopened=window_title
MessageModal>%justopened%
SetFocus>justopened
WindowAction>1,justopened
Wait>2
WindowAction>2,justopened
If you hot key this(macroproperties/hot key)and then run it over and over, you'll see the window handle is changing for each new notepad window opened, even though EACH WINDOW TITLE IS EXACTLY THE SAME AS ALL THE OTHERS. The Maximize/Minimize moves are to convince me that that window is really the one being worked on. When the Message appears hit the spacebar, or the letter o, or the enter key to continue.
Let>WIN_USEHANDLE=1
Let>MSGSTAYONTOP=1
ExecuteFile>C:\WINDOWS\notepad.exe
WaitReady>1
Wait>0.5
GetActiveWindow>window_title,X,Y
Let>justopened=window_title
MessageModal>%justopened%
SetFocus>justopened
WindowAction>1,justopened
Wait>2
WindowAction>2,justopened