Sign in to follow this  
Followers 0
tommeke228

Get the title of an program

10 posts in this topic

#1 ·  Posted (edited)

i need the code to get the procces ID first

and then somethings that gets the title with the process ID

i found this but wtf i need the title to get the title xD

WinGetTitle ( "title" [, "text"] )

(Its an CLIENT)

(and the proccesname is "SRO_Client.exe")

Thx

Edited by tommeke228

Share this post


Link to post
Share on other sites



comon

Share this post


Link to post
Share on other sites

comon

Hello,

Be polite first and then use Au3Info.exe....


No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE

Share this post


Link to post
Share on other sites

Hello,

Be polite first and then use Au3Info.exe....

lol but uhm the program must know the program not me xD

Share this post


Link to post
Share on other sites

A process can have several windows, that's possibly why there ain't a default, built-in function to do this, however, you can use one of my functions to retrieve the window(s) that a process owns:

$aWindows = _ProcessGetWinEx("SRO_Client.exe")
For $i = 1 To $aWindows[0]
      ConsoleWrite("Found a window, with title:" & WinGetTitle($aWindows[$i]) & @LF)
Next

Func _ProcessGetWinEx($ivPid, $svClass = "", $svTitle = "", $svText = "", $ivReturnOnlyFirstMatch = False)
   
    $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

Or, if the process only creates one window, you can use the last parameter of my function, and it will only return the first window.

$hWindow = _ProcessGetWinEx("SRO_Client.exe", "", "", "", True)
ConsoleWrite("Window title: " & WinGetTitle($hWindow) & @LF)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

A process can have several windows, that's possibly why there ain't a default, built-in function to do this, however, you can use one of my functions to retrieve the window(s) that a process owns:

$aWindows = _ProcessGetWinEx("SRO_Client.exe")
For $i = 1 To $aWindows[0]
      ConsoleWrite("Found a window, with title:" & WinGetTitle($aWindows[$i]) & @LF)
Next

Func _ProcessGetWinEx($ivPid, $svClass = "", $svTitle = "", $svText = "", $ivReturnOnlyFirstMatch = False)
   
    $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

Or, if the process only creates one window, you can use the last parameter of my function, and it will only return the first window.

$hWindow = _ProcessGetWinEx("SRO_Client.exe", "", "", "", True)
ConsoleWrite("Window title: " & WinGetTitle($hWindow) & @LF)
thx gona try it

EDIT

it finds this

Window title: Mercury - KillahPH

and this

found a window, with title:Mercury - KillahPH

Found a window, with title:Toucan IPC Window

Found a window, with title:DIEmWin

Found a window, with title:M

Found a window, with title:Default IME

Found a window, with title:Default IME

(but if i have 2 clients then its only finds the first 1 not the other one )

its only finding "Mercury - KillahPH" but its need to find another one muttley

Edited by tommeke228

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Then you need to enumerate the two processes. Perhaps something like this?:

$aProcesses = ProcessList("SRO_Client.exe")

For $i = 1 To $aProcesses[0][0]
    $aWindows = _ProcessGetWinEx($aProcesses[$i][1])
    For $b = 1 To $aWindows[0]
        ConsoleWrite("Found a window, with title:" & WinGetTitle($aWindows[$b]) & @LF)
    Next
Next

My function accepts a process name, and also the Process Identifier(PID), so basically what we're doing here is Listing all processes that is named "SRO_Client.exe", then looping through them, acquiring all their windows, and printing the window titles.

Edit:

For a more practical use, you could do something like this:

Dim $aClients[1] = [0]; Create an array, which we will use to store all the window handles.

$aProcesses = ProcessList("SRO_Client.exe")

;Retrieve and store all matching processes, windows.
For $i = 1 To $aProcesses[0][0]
    $hWindow = _ProcessGetWinEx($aProcesses[$i][1], "", "", "", True); Retrieves the first window.
    If WinExists($hWindow) Then
        $aClients[0] += 1
        ReDim $aClients[$aClients[0]+1]
        $aClients[$aClients[0]] = $hWindow
    EndIf
Next

;Loop through the windows found.
For $i = 1 To $aClients[0]
    ConsoleWrite("A window was found: " & WinGetTitle($aClients[$i]) & @LF)
Next

It will get all windows, by all processes named "SRO_Client.exe", and store them in an array, for later use(which is probably what you want). muttley

Edited by FreeFry

Share this post


Link to post
Share on other sites

Then you need to enumerate the two processes. Perhaps something like this?:

$aProcesses = ProcessList("SRO_Client.exe")

For $i = 1 To $aProcesses[0][0]
    $aWindows = _ProcessGetWinEx($aProcesses[$i][1])
    For $b = 1 To $aWindows[0]
        ConsoleWrite("Found a window, with title:" & WinGetTitle($aWindows[$b]) & @LF)
    Next
Next

My function accepts a process name, and also the Process Identifier(PID), so basically what we're doing here is Listing all processes that is named "SRO_Client.exe", then looping through them, acquiring all their windows, and printing the window titles.

Edit:

For a more practical use, you could do something like this:

Dim $aClients[1] = [0]; Create an array, which we will use to store all the window handles.

$aProcesses = ProcessList("SRO_Client.exe")

;Retrieve and store all matching processes, windows.
For $i = 1 To $aProcesses[0][0]
    $hWindow = _ProcessGetWinEx($aProcesses[$i][1], "", "", "", True); Retrieves the first window.
    If WinExists($hWindow) Then
        $aClients[0] += 1
        ReDim $aClients[$aClients[0]+1]
        $aClients[$aClients[0]] = $hWindow
    EndIf
Next

;Loop through the windows found.
For $i = 1 To $aClients[0]
    ConsoleWrite("A window was found: " & WinGetTitle($aClients[$i]) & @LF)
Next

It will get all windows, by all processes named "SRO_Client.exe", and store them in an array, for later use(which is probably what you want). muttley

really thx xD ^^

Share this post


Link to post
Share on other sites

No problem, hope you understand, and learn something of it. muttley

Share this post


Link to post
Share on other sites

No problem, hope you understand, and learn something of it. muttley

jep really thx its working perfect xD

Share this post


Link to post
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
Sign in to follow this  
Followers 0