Jump to content

use of classname with winactivate etc how to find one


Recommended Posts

Maybe you can use Opt("WinTitleMatchMode", 2) to match only the "Adobe Reader" string (it is at the end of the Window title).

If the process name is the only information you have, then you can use something like this :

$res = _WinGetFromProcess("notepad.exe")
MsgBox(0, "", "Window title for notepad : " & $res)

$res = _WinGetFromProcess("notepad.exe", 1)
MsgBox(0, "", "Window handle for notepad : " & $res)

; Returns the Windows Title or Handle, from a Process name or PID
; Process : ProcessName or PID
; iFlag : 0 = returns the title
;         1 = returns the handle
Func _WinGetFromProcess($Process, $iFlag = 0)
    Local $aProcessList = ProcessList($Process)
    
    Local $aWinList = WinList()

    For $i = 1 To $aWinList[0][0]
        If $aWinList[$i][0] <> "" And BitAND(WinGetState($aWinList[$i][1]), 2) Then
            $iPid = WinGetProcess($aWinList[$i][1])
            For $j = 1 To $aProcessList[0][0]
                If $aProcessList[$j][0] = $iPid OR $aProcessList[$j][1]= $iPid Then
                    If $iFlag Then
                        Return $aWinList[$i][1]
                    Else
                        Return $aWinList[$i][0]
                    EndIf
                EndIf
            Next
        EndIf
    Next
    
    Return 0
EndFunc
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...