#include-once Func _WinGetTitleEx($ExTitle) If IsHWnd($ExTitle) Then Return WinGetTitle($ExTitle) Local $OldOpt = Opt("WinTitleMatchMode", 2) If StringLeft($ExTitle, 7) = "hidden=" Then $ExTitle = WinGetTitle(StringTrimLeft($ExTitle, 7)) If Not _IsVisible($ExTitle) Then Opt("WinTitleMatchMode", $OldOpt) Return $ExTitle EndIf EndIf Local $RetTitle = _PathIsProcess($ExTitle) If $RetTitle Then $RetTitle = _WinGetTitleByPID($RetTitle) If ProcessExists($ExTitle) Then $RetTitle = _WinGetTitleByPID($ExTitle) If Not $RetTitle Then $RetTitle = WinGetTitle($ExTitle) If Not WinExists($RetTitle) Or Not $RetTitle Then Opt("WinTitleMatchMode", 4) $RetTitle = WinGetTitle($ExTitle) If Not $RetTitle Then $RetTitle = WinGetTitle("regexp=(?i)(.*)" & $ExTitle & "(.*)") EndIf Opt("WinTitleMatchMode", $OldOpt) Return $RetTitle EndFunc Func _WinGetTitleByPID($iPID, $nArray = 1) If IsString($iPID) Then $iPID = ProcessExists($iPID) Local $aWList = WinList(), $sHold For $iCC = 1 To $aWList[0][0] If WinGetProcess($aWList[$iCC][1]) = $iPID And _ BitAND(WinGetState($aWList[$iCC][1]), 2) Then If $nArray Then Return $aWList[$iCC][0] $sHold &= $aWList[$iCC][0] & Chr(1) EndIf Next If $sHold Then Return StringSplit(StringTrimRight($sHold, 1), Chr(1)) Return SetError(1, 0, 0) EndFunc Func _PathIsProcess($sPath) If Not FileExists($sPath) Then Return SetError(1, 0, False) Local $ObjWMIService, $ProcItems, $Extended = 0 Local $sPathName = StringRegExpReplace($sPath, "^.*\\", "") If Not ProcessExists($sPathName) Then Return SetError(2, 0, False) Local $ProcessList = ProcessList($sPathName) $Extended = UBound($ProcessList)-1 For $i = 1 To $Extended $ObjWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2") $ProcItems = $ObjWMIService.ExecQuery ("SELECT * FROM Win32_Process WHERE ProcessId = " & $ProcessList[$i][1], "WQL", 0x30) If IsObj($ProcItems) Then For $ObjItem In $ProcItems If $ObjItem.ExecutablePath = $sPath Then Return SetExtended($Extended, $ObjItem.ProcessID) Next EndIf Next Return SetExtended($Extended, False) EndFunc Func _IsVisible($Title) Return BitAND(WinGetState($Title), 2) EndFunc