Jump to content

How to make window active that is a specific class and also has a specific window title?


Recommended Posts

Posted

Hi,

Is there any way in Autoit to make a specific window active that is of a certain class AND has a specific title?   The reason is that I have multiple instances of windows of the same class  but different titles (captions) and I want a specific window to come to the front with a Autoit command. 

Thanks

Kris

Posted

See WinList using "Title Special Definition" class option.  You will get an array of all the windows with a very specific class.  Parse the array to find the exact title you are looking for.  It will give you a unique handle that you could use to bring the window in front.

Posted (edited)

@KDoc

WinActivate(_WinGetByTC("CalcFrame", "Calculator"));active window by title = Calculator & class=CalcFrame
Func _WinGetByTC($class, $title)
    Local $WIN = WinList("[CLASS:" & $class & "]")
    For $i = 0 To UBound($WIN)
        If $WIN[$i][1] <> "" Then
            If $title = WinGetTitle($WIN[$i][1]) Then
                Return $WIN[$i][1]
            EndIf
        EndIf
    Next
EndFunc   ;==>_WinGetByTC

 

Edited by ad777

none

Posted

Not quite.  WinList returns a 1-based array.  And there is no need to retrieve the title again since WinList already give it. Streamlined :

WinActivate(_WinGetByTC("CalcFrame", "Calculator"));active window by title = Calculator & class=CalcFrame
Func _WinGetByTC($class, $title)
    Local $WIN = WinList("[CLASS:" & $class & "]")
    For $i = 1 To $WIN[0][0]
        If $WIN[$i][0] = $title Then Return $WIN[$i][1]
    Next
EndFunc   ;==>_WinGetByTC

 

  • 10 months later...

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
  • Recently Browsing   0 members

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