Basic Question: Can't focus on a specific window

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
ADP_MAN
Junior Coder
Posts: 45
Joined: Wed Apr 07, 2004 2:04 pm

Basic Question: Can't focus on a specific window

Post by ADP_MAN » Thu Oct 21, 2004 8:33 pm

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.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Thu Oct 21, 2004 9:12 pm

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:
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!

ADP_MAN
Junior Coder
Posts: 45
Joined: Wed Apr 07, 2004 2:04 pm

Post by ADP_MAN » Tue Nov 09, 2004 7:48 pm

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.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Nov 09, 2004 11:19 pm

1. I see (or cannot see) a missing space character before Notepad:
"Untitled -Notepad*
2. When you did Cut/Paste, did you remove all Trailing Spaces in the script before running it?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

jlbt51

Window not present

Post by jlbt51 » Mon Nov 22, 2004 3:08 am

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>/.

User avatar
Monkster
Junior Coder
Posts: 42
Joined: Fri Oct 04, 2002 9:37 pm
Location: On an Island with Wilson

Post by Monkster » Mon Nov 22, 2004 6:41 am

Another thing you may want to have a look at FindWindowWithText in the help file. It mentions the utility and suggests that you may find some information of value there. Wish I could be of more assistance, you've probably already been there done that :wink:
Best Wishes,
Monkster

jalbt51
Junior Coder
Posts: 31
Joined: Sat Mar 06, 2004 4:40 pm

Window Handle picks between identically titled windows

Post by jalbt51 » Mon Nov 22, 2004 6:42 pm

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

ADP_MAN
Junior Coder
Posts: 45
Joined: Wed Apr 07, 2004 2:04 pm

Post by ADP_MAN » Mon Jan 17, 2005 3:48 pm

Thanks for all the help!

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