Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Run("notepad.exe")
- Sleep(1000) ; chờ notepad bật
- $pid = ProcessExists("notepad.exe") ; lấy process id
- $hwnd = _ProcessGetWinEx($pid) ; lấy win handle từ process
- MsgBox(0, "", WinGetTitle($hwnd)) ; title
- Func _ProcessGetWinEx($ivPid, $svClass = "", $svTitle = "", $svText = "", $ivReturnOnlyFirstMatch = True)
- $ivPid = ProcessExists($ivPid)
- If Not $ivPid Then Return(SetError(1, 0, 0))
- Local $avwArray = WinList()
- Local $avRet[1] = [0]
- For $i = 1 To $avwArray[0][0]
- $avClass = DllCall("User32.dll", "int", "GetClassName", "hwnd", $avwArray[$i][1], "str", "", "int", 4096)
- If WinGetProcess($avwArray[$i][1]) = $ivPid Then
- If $svClass = "" Or (IsArray($avClass) And $avClass[2] = $svClass) Then
- If ($svTitle = "" Or StringInStr($avwArray[$i][0], $svTitle)) And ($svText = "" Or StringInStr(WinGetText($avwArray[$i][1]), $svText)) Then
- $avRet[0] += 1
- ReDim $avRet[$avRet[0]+1]
- $avRet[$avRet[0]] = $avwArray[$i][1]
- If $ivReturnOnlyFirstMatch Then
- $avRet = $avret[1]
- ExitLoop
- EndIf
- EndIf
- EndIf
- EndIf
- Next
- Return $avRet
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement