Difficulty with setfocus

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
ScottT1980
Newbie
Posts: 1
Joined: Sat Oct 31, 2009 5:53 pm

Difficulty with setfocus

Post by ScottT1980 » Sat Oct 31, 2009 6:00 pm

This has probably been discussed ad nauseam, but I am having difficulty focusing on a window of interest. I am attempting to use recording software to record a daily webcast while afk. However, I am having difficulty getting MS to focus on the window. The software is MP3 My MP3 3.0.

Here are the basic commands at this point:

Code: Select all

ExecuteFile>C:\Users\Scott\AppData\Local\Google\Chrome\Application\chrome.exe,
wait>5
setfocus>New Tab - Google Chrome
let>url=http://player.play.it/player/player.htmlv=4.9.24b&id=61&onestat=wfnz-am
send>url
Press Enter
mousemoverel>706,10
lclick
wait>5

ExecuteFile>C:\Program Files\MP3MyMP3 3.0\MP3MyMP3 3.0.exe,
wait>10
Setfocus>MP3 My MP3 3.0*
Mousemoverel>16,45
lclick
I have tried asterisks, using Tools>View System Windows to view window titles, etc... and nothing I have tried seems to focus on the software to push the record button. I feel like I am missing something very simple...any help? Also, is there an easier way to determine a window title?

Thanks in advance!

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

Post by JRL » Sun Nov 01, 2009 4:35 am

Try this:

Modifying a program by Wahnfang found HERE to run through all the windows on the computer until a text match is found then acquire the handle to that window and setfocus to the window via its handle.

Note: The window name text being searched is case sensitive.

Code: Select all

Let>WindowNameText=MP3 My MP3 3.0

Let>WIN_USEHANDLE=1
// Just to get one Hwnd
GetActiveWindow>win,x,y
// Just to get the first Hwnd
Let>gw=0
Label>start
LibFunc>user32,GetWindow,win,%win%,%gw%
//Now the next ones
Let>gw=2
// Bye bye after the last Hwnd
If>win=0,fin
LibFunc>user32,GetWindowTextLengthA,wtlen,win
Let>buffer_SIZE=wtlen
Let>wtlen=wtlen+1
LibFunc>user32,GetWindowTextA,gwt,win,buffer,wtlen
// Is gwt_2 closed with Ascii 0? You can't put another text or variable after gwt_2! Any solution?
//MessageModal>Text: %gwt_2%
separate>%gwt_2%,%WindowNameText%,res
If>res_Count>1,display
If>wtlen>1000
  GoSub>fin
EndIf
Goto>start
Label>display
//mdl>Name= %gwt_2% Handle= %gwt_1%
SetFocus>%gwt_1%
Let>WIN_USEHANDLE=1

SRT>fin
  MDL>%WindowNameText% not found
  Exit>0
END>fin


idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

Post by idiot » Fri Nov 27, 2009 2:41 am

blah his way works but to complicated just use waitwindowopen command before you setfocus
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

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