Can't Focus on a window without title.Focus using ClassName?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Spudwars
Newbie
Posts: 13
Joined: Fri Dec 09, 2005 1:01 pm

Can't Focus on a window without title.Focus using ClassName?

Post by Spudwars » Fri Dec 09, 2005 1:21 pm

I have a problem...

I am trying to ensure that a program on our server, AGS, is closed before processing another instance of AGS. The trouble is, if it is logged in I can close it no problem (ALT + fx), but if it is only at the login screen - I just need to focus on it and Press ESC or Cancel. But this window does not have a title bar, nor does it have a title. How does one set focus to a window that has no title name?

There could be many instances of this open, so I would like a short loop to focus each Login screen and close it one by one.

Using Tools > Open Windows, I have discovered which window ID relates to the AGS windows open (i opened 5 instances and looked for duplicates, then right clicked > Show Window and it came to front). The details listed under Open Windows are as follows:
+263270 - FNWNS390 ""
- 656432 - Button "Build 20050309"
- 656478 - Button "V10.0"
- 197922 - Button "&OK"
- 328944 - Button "Cancel"
- 197936 - Button ""
- 721954 - Button ""
- 263342 - Button ""
- 263340 - Button "This computer program is the property of SAGEM SA. Use, examination, copying, transfer and disclosure to others, in whole or in part, are prohibited except with the prior
written consent of SAGEM SA."
- 394450 - Button "Password"
- 328948 - Button "Login Name"
- 722018 - Edit ""
- 721970 - Edit "AUTO"
- 721980 - Button ""
As you can see, the Window is FNWNS390 "". Now without a description, one cannot use the 'SetFocus>' command to link to it. I'm assuming that FNWNS390 is the ClassName? Therefore, is it possible to SetFocus or similar to a window by using the ClassName? I can't use the PID as the process number will change for each instance and will never be the same on different days.

I created some code to get details from the program, I have included it below so you can understand the situation further:

GetActiveWindow>title,x,y
GetWindowHandle>%title%,handle
GetWindowProcess>%title%,pid,pname
MessageModal>Title: %title% - Handle: %handle% - Process ID: %pid% - Process Name: %pname%



On Macro Scheduler Window, Returns:
Title: Macro Scheduler 8.0 beta 007 - Handle: 3277072 - Process ID: 4088 - Process Name: C:\Program Files\MJT Net Ltd\Macro Scheduler\msched.exe
On AGS Login Window, Returns:
Title: - Handle: 0 - Process ID: 0 - Process Name:
I am using the new Beta v.8.0.

GetControlText uses the ClassName feature, but I don't think that this will do anything like what I need?!

Please can you help me? I'm stumped for ideas now!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Dec 09, 2005 2:11 pm

Do this:


LibFunc>user32,FindWindowA,hWnd,FNWNS390,
Let>WIN_USEHANDLE=1
SetFocus>hWnd
Let>WIN_USEHANDLE=0
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Spudwars
Newbie
Posts: 13
Joined: Fri Dec 09, 2005 1:01 pm

Post by Spudwars » Fri Dec 16, 2005 2:50 pm

Thank you very much, just tried it out and it works well. Thank you.

Do you know where I can find more information on user32 functions?

Thanks

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Dec 16, 2005 3:34 pm

See my reply to your other post on this subject.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

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