Jump to content

Highlight a particular window?


Recommended Posts

I was looking at the winactivate command and it seemed like that would be what I am looking for but it didn't seem to work. Lets say you have a lot of windows opened and you want autoit to find and open a particular window as if you alt tabbed to it, can you do that with winactivate or any other command?

Link to comment
Share on other sites

Hello noobieautolearn,

Read up on these two topics, both found in your help file, and the online documentation

Window Titles and Text (Basic)

Window Titles and Text (Advanced)

These two pages will help you understand how to take full advantage of functions that utilize Window Titles. If you have other Windows that have similar names, the basic approach with default parameters will find all or one of the many. However If you target a window by classname, this will define it down to application type. Adding a text parameter will help define the windows even more if text varies between the different windows. Also If you application is creating the instance of the window you are attempting to bring back into focus, you should provide a way to obtain the unique handle of the window during creation, which will be the most direct way to identify the window in need. There are many approaches and ways to define your code to find the exact window that is needed and called upon. However, when you do not provide more information, like the process name, or window name, then its difficult for us to point you in the necessary direction. If you read up on those two pages I suggested, I am more than certain that you will find a way to obtain the window of choice fairly easily.

Good Luck & Happy Coding!

Realm

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

Hello noobieautolearn,

Read up on these two topics, both found in your help file, and the online documentation

Window Titles and Text (Basic)

Window Titles and Text (Advanced)

These two pages will help you understand how to take full advantage of functions that utilize Window Titles. If you have other Windows that have similar names, the basic approach with default parameters will find all or one of the many. However If you target a window by classname, this will define it down to application type. Adding a text parameter will help define the windows even more if text varies between the different windows. Also If you application is creating the instance of the window you are attempting to bring back into focus, you should provide a way to obtain the unique handle of the window during creation, which will be the most direct way to identify the window in need. There are many approaches and ways to define your code to find the exact window that is needed and called upon. However, when you do not provide more information, like the process name, or window name, then its difficult for us to point you in the necessary direction. If you read up on those two pages I suggested, I am more than certain that you will find a way to obtain the window of choice fairly easily.

Good Luck & Happy Coding!

Realm

I will continue to work with it but The window Title is New Host, Window class is #32770 handle 0x0010139E

Control is Class:static

ClassnameNN Static2

Advanced (Class) [CLASS:Static; INSTANCE:2]

ID: 65535.

Visible text

IP Address/Host Name/&Machine Name:

Anyway I don't have time right now but will try to experiment. I guess I'm just curious on the syntax but also if this command can pick this window out of a bunch of opened windows even if it isn't currently the focus.

What I am doing is running the autoitscript with a keyboard combination shortcut and when I do that it delects this particular window, even if I alt tab it does not go right back to that window even though it was the last window I had highlighted.

Link to comment
Share on other sites

Hello noobieautolearn,

If the window is active with focus at a given point in your script, then your solution is easy. Use WinGetHandle( "[ACTIVE]" ) while the window is active and in current focus. Then call with the handle at the point you need

Example:

$hWin = WinGetHandle( "[ACTIVE]" )
;do something
;do something
;activate as many windows as you like.

;Activate The window when needed
WinWaitActive( $hWin )

Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

Be sure to use the "AutoIt Window Info" application to identify the exact title of the window you're attempting to change focus to (assuming it's previously created and static). To do this, go to C:AutoInstallLocationAu3Info.exe (or the x64 version if needed).

Click and drag the "Finder Tool" to the window to which you'd like to change focus. The title can be found in the "Title:" field.

Link to comment
Share on other sites

Hello noobieautolearn,

If the window is active with focus at a given point in your script, then your solution is easy. Use WinGetHandle( "[ACTIVE]" ) while the window is active and in current focus. Then call with the handle at the point you need

Example:

$hWin = WinGetHandle( "[ACTIVE]" )
;do something
;do something
;activate as many windows as you like.

;Activate The window when needed
WinWaitActive( $hWin )

Realm

Well I tried adding this to the script but it did not work, do I need to type something in place of active?

I just added

$hWin = WinGetHandle( "[ACTIVE]" )

and then WinWaitActive( $hWin ) to the top and bottom of the script I wrote, I assumed that the ( "[ACTIVE]" ) would be whatever window was active when the script started. It seems to not leave that window highlighted as soon as the script starts.

I have found kind of a work around for this at the moment by just telling the script to left click at it's current location at the start but I would like to learn how to highlight the window through other means.

Link to comment
Share on other sites

Hello noobieautolearn,

'Active' means current focus, not the previous focus. When you execute your script, the 'active' focus is no longer on the window. It will likely return the handle to Scite, if exectued from there. It may return an explorer window handle, or no handle, all depending on where the script was executed from.

In previous posts, it sounded to me as if your script was starting this application. Now it sounds as if the application is already active and opened upon execution of your script. In this case, the example I provided will not work.

Obtaining the handle, outside of the script, will work for the duration the window is open. However, after it has been closed then reopened, a new handle more than likely will be assigned, so this will not be a suggestive way to work with the window, unless of coarse there is a way to obtain the handle via script, through another source of identification.

Earlier you mentioned visible text being 'IP Address/Host Name/&Machine Name:' Is there a chance this text will be found on one of the duplicate windows? If not, you can easily call the window with _WinWaitActivate( "New Host", "IP Address/Host Name/&Machine Name"). However if one or more of the duplicate windows may contain this text, it may not work as desired. If this is the case, then is there any identifiable text in the window, that will be sure to differ from the other windows? or Do you know if it will be [iNSTANCE:2] every time, or may the instance vary?

Realm

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...