Jump to content

Get Title from PID


Recommended Posts

Hello I'v Resently Been Verry active at the forums and i have returned to learning AutoIt muttley

I'v Got a question:

How Can I Get All The Titles Of Active Windows that have the name "Sro_Client.exe" in process list at the taskmaneger ?

Can Someone show me or just decompile the attached exe

the exe's from a friend there it's shown how but when i decompile ..... 10000 lines of Global const etc ..

Have Questions About GUI (Graphical User Interface) ? Post Them Here :GUI Help And Support ForumHave Questions About General AutoIt ? Post Them Here : General Help And Support ForumNew To AutoIt ? Be Shure To Check Out The FaQ's (Frequently Asked Questions) Or FaQ ¹ There You May Find Great Help That Will Guide You True The Wonderful Programming Language AutoItOthere Good Place To Get Some Knolage Of AutoIt Is The Example Script ForumNotice A Bug ? Please Go And Report it At Bug Report Section And Help The Devolepers Of AutoIt Update And Fix The Programming LanguageWant To Thank The People For This Great Forum And Programming Language ? Then DonateWhen You Found The Answer Your Looking For Please Add [Resolved] To The Thread's Name That Will Show Otheres That You Have Found What Your Looking For And They Whount Have To Enter The Thread.

Link to comment
Share on other sites

Here:

#include <Process.au3>

dim $string

$exe_name = "notepad.exe"
$winlist = WinList ()

For $i = 1 To $winlist[0][0]
    If _ProcessGetName (WinGetProcess ($winlist[$i][0])) = $exe_name Then
        $string =  $string & $winlist[$i][0] & @TAB & _ProcessGetName (WinGetProcess ($winlist[$i][0])) &  @TAB & WinGetProcess ($winlist[$i][0]) & @CRLF
    EndIf
Next

MsgBox(0,"",$string)
Exit

That should did what you want, just change $exe_name to that what you need

Link to comment
Share on other sites

thank you but can i make a request muttley can you make it show the title or titles if there is more than one executed with that PID in a listbox or combobox ? ty alot

Have Questions About GUI (Graphical User Interface) ? Post Them Here :GUI Help And Support ForumHave Questions About General AutoIt ? Post Them Here : General Help And Support ForumNew To AutoIt ? Be Shure To Check Out The FaQ's (Frequently Asked Questions) Or FaQ ¹ There You May Find Great Help That Will Guide You True The Wonderful Programming Language AutoItOthere Good Place To Get Some Knolage Of AutoIt Is The Example Script ForumNotice A Bug ? Please Go And Report it At Bug Report Section And Help The Devolepers Of AutoIt Update And Fix The Programming LanguageWant To Thank The People For This Great Forum And Programming Language ? Then DonateWhen You Found The Answer Your Looking For Please Add [Resolved] To The Thread's Name That Will Show Otheres That You Have Found What Your Looking For And They Whount Have To Enter The Thread.

Link to comment
Share on other sites

Here it is:

#NoTrayIcon

#include <GUIConstantsEx.au3>
#include <GUIListView.au3>

#include <ListviewConstants.au3>
#include <WindowsConstants.au3>

#include <Process.au3>
#include <Array.au3>

$exe_name = "notepad.exe"
$winlist = WinList ()

dim $string[1]

GUICreate("Process2Title", 200, 200, (@DesktopWidth-200)/2, (@DesktopHeight-200)/2, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST))

$listview = GUICtrlCreateListView ("PID|Process|WinTitle", 4,4,192,192)

dim $B_DESCENDING[_GUICtrlListView_GetColumnCount($listview)]
_GUICtrlListView_SetColumnWidth($listview, 1, $LVSCW_AUTOSIZE)


For $i = 1 To $winlist[0][0]
    If _ProcessGetName (WinGetProcess ($winlist[$i][0])) = $exe_name Then
        GUICtrlCreateListViewItem (WinGetProcess ($winlist[$i][0]) & "|" & _ProcessGetName (WinGetProcess ($winlist[$i][0])) &  "|" & $winlist[$i][0], $listview)
    EndIf
Next

GUISetState ()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

Exit
Link to comment
Share on other sites

thanks but i got this crazy shit let me explain:

it works almost perfect the only problem is :

ok it get's the title it's Mercury - SouLGuarDiaN

but it enteres 10 more titles to same process at the list and shows title "M" Oo wtf ?

Have Questions About GUI (Graphical User Interface) ? Post Them Here :GUI Help And Support ForumHave Questions About General AutoIt ? Post Them Here : General Help And Support ForumNew To AutoIt ? Be Shure To Check Out The FaQ's (Frequently Asked Questions) Or FaQ ¹ There You May Find Great Help That Will Guide You True The Wonderful Programming Language AutoItOthere Good Place To Get Some Knolage Of AutoIt Is The Example Script ForumNotice A Bug ? Please Go And Report it At Bug Report Section And Help The Devolepers Of AutoIt Update And Fix The Programming LanguageWant To Thank The People For This Great Forum And Programming Language ? Then DonateWhen You Found The Answer Your Looking For Please Add [Resolved] To The Thread's Name That Will Show Otheres That You Have Found What Your Looking For And They Whount Have To Enter The Thread.

Link to comment
Share on other sites

can u try it with a combobox it think it will work better for this thing muttley

Have Questions About GUI (Graphical User Interface) ? Post Them Here :GUI Help And Support ForumHave Questions About General AutoIt ? Post Them Here : General Help And Support ForumNew To AutoIt ? Be Shure To Check Out The FaQ's (Frequently Asked Questions) Or FaQ ¹ There You May Find Great Help That Will Guide You True The Wonderful Programming Language AutoItOthere Good Place To Get Some Knolage Of AutoIt Is The Example Script ForumNotice A Bug ? Please Go And Report it At Bug Report Section And Help The Devolepers Of AutoIt Update And Fix The Programming LanguageWant To Thank The People For This Great Forum And Programming Language ? Then DonateWhen You Found The Answer Your Looking For Please Add [Resolved] To The Thread's Name That Will Show Otheres That You Have Found What Your Looking For And They Whount Have To Enter The Thread.

Link to comment
Share on other sites

#NoTrayIcon

#include <GUIConstantsEx.au3>
#include <GUIListView.au3>

#include <ListviewConstants.au3>
#include <WindowsConstants.au3>

#include <Process.au3>
#include <Array.au3>

$exe_name = "notepad.exe"

$winlist = ProcessList ("notepad.exe")

GUICreate("Process2Title", 200, 200, (@DesktopWidth-200)/2, (@DesktopHeight-200)/2, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST))

$listview = GUICtrlCreateListView ("PID|Process|WinTitle", 4,4,192,192)

dim $B_DESCENDING[_GUICtrlListView_GetColumnCount($listview)]
_GUICtrlListView_SetColumnWidth($listview, 1, $LVSCW_AUTOSIZE)


For $i = 1 To $winlist[0][0]
    GUICtrlCreateListViewItem ($winlist[$i][1] & "|" & $winlist[$i][0] &  "|" & WinGetTitle(_ProcessGetWinEx($winlist[$i][0],"","","",True)), $listview)
Next

GUISetState ()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

Exit

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

Thanks to FreeFry for his _ProcessGetWinEx

Link to comment
Share on other sites

Thanks Alot !!!!!! muttley now works great sorry for this but 1 last thing

can u make it show the process in a combobox nd only the title :) (verry sorry for so many requests)

Have Questions About GUI (Graphical User Interface) ? Post Them Here :GUI Help And Support ForumHave Questions About General AutoIt ? Post Them Here : General Help And Support ForumNew To AutoIt ? Be Shure To Check Out The FaQ's (Frequently Asked Questions) Or FaQ ¹ There You May Find Great Help That Will Guide You True The Wonderful Programming Language AutoItOthere Good Place To Get Some Knolage Of AutoIt Is The Example Script ForumNotice A Bug ? Please Go And Report it At Bug Report Section And Help The Devolepers Of AutoIt Update And Fix The Programming LanguageWant To Thank The People For This Great Forum And Programming Language ? Then DonateWhen You Found The Answer Your Looking For Please Add [Resolved] To The Thread's Name That Will Show Otheres That You Have Found What Your Looking For And They Whount Have To Enter The Thread.

Link to comment
Share on other sites

i promice this is my last request muttley

Have Questions About GUI (Graphical User Interface) ? Post Them Here :GUI Help And Support ForumHave Questions About General AutoIt ? Post Them Here : General Help And Support ForumNew To AutoIt ? Be Shure To Check Out The FaQ's (Frequently Asked Questions) Or FaQ ¹ There You May Find Great Help That Will Guide You True The Wonderful Programming Language AutoItOthere Good Place To Get Some Knolage Of AutoIt Is The Example Script ForumNotice A Bug ? Please Go And Report it At Bug Report Section And Help The Devolepers Of AutoIt Update And Fix The Programming LanguageWant To Thank The People For This Great Forum And Programming Language ? Then DonateWhen You Found The Answer Your Looking For Please Add [Resolved] To The Thread's Name That Will Show Otheres That You Have Found What Your Looking For And They Whount Have To Enter The Thread.

Link to comment
Share on other sites

i hope so!

#NoTrayIcon

#include <GUIConstantsEx.au3>


#include <WindowsConstants.au3>

#include <Process.au3>
#include <Array.au3>

$exe_name = "notepad.exe"

$winlist = ProcessList ($exe_name)

GUICreate("Process2Title", 200, 28, (@DesktopWidth-200)/2, (@DesktopHeight-28)/2, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST))

$combo = GUICtrlCreateCombo ("", 4,4,192,20)



For $i = 1 To $winlist[0][0]
    GUICtrlSetData ($combo, WinGetTitle(_ProcessGetWinEx($winlist[$i][0],"","","",True)))
Next

GUISetState ()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

Exit

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

edited!

Edited by yetrael
Link to comment
Share on other sites

umm now it says "sro_client.exe - Merucry - SouLGuardian" can u remove the sro_client.exe and leave only the title ? :S

sorry :S

Have Questions About GUI (Graphical User Interface) ? Post Them Here :GUI Help And Support ForumHave Questions About General AutoIt ? Post Them Here : General Help And Support ForumNew To AutoIt ? Be Shure To Check Out The FaQ's (Frequently Asked Questions) Or FaQ ¹ There You May Find Great Help That Will Guide You True The Wonderful Programming Language AutoItOthere Good Place To Get Some Knolage Of AutoIt Is The Example Script ForumNotice A Bug ? Please Go And Report it At Bug Report Section And Help The Devolepers Of AutoIt Update And Fix The Programming LanguageWant To Thank The People For This Great Forum And Programming Language ? Then DonateWhen You Found The Answer Your Looking For Please Add [Resolved] To The Thread's Name That Will Show Otheres That You Have Found What Your Looking For And They Whount Have To Enter The Thread.

Link to comment
Share on other sites

never mind found it thanks for all your help bro respect for you muttley

Have Questions About GUI (Graphical User Interface) ? Post Them Here :GUI Help And Support ForumHave Questions About General AutoIt ? Post Them Here : General Help And Support ForumNew To AutoIt ? Be Shure To Check Out The FaQ's (Frequently Asked Questions) Or FaQ ¹ There You May Find Great Help That Will Guide You True The Wonderful Programming Language AutoItOthere Good Place To Get Some Knolage Of AutoIt Is The Example Script ForumNotice A Bug ? Please Go And Report it At Bug Report Section And Help The Devolepers Of AutoIt Update And Fix The Programming LanguageWant To Thank The People For This Great Forum And Programming Language ? Then DonateWhen You Found The Answer Your Looking For Please Add [Resolved] To The Thread's Name That Will Show Otheres That You Have Found What Your Looking For And They Whount Have To Enter The Thread.

Link to comment
Share on other sites

1 more problem occured when i execute 1 more process ( in process list it's sro_client.exe like the fist one ) it dousnt show in the combo box :S can u make it show all the process called sro_client.exe's titles that are executed to be shown in the combobox ?

Have Questions About GUI (Graphical User Interface) ? Post Them Here :GUI Help And Support ForumHave Questions About General AutoIt ? Post Them Here : General Help And Support ForumNew To AutoIt ? Be Shure To Check Out The FaQ's (Frequently Asked Questions) Or FaQ ¹ There You May Find Great Help That Will Guide You True The Wonderful Programming Language AutoItOthere Good Place To Get Some Knolage Of AutoIt Is The Example Script ForumNotice A Bug ? Please Go And Report it At Bug Report Section And Help The Devolepers Of AutoIt Update And Fix The Programming LanguageWant To Thank The People For This Great Forum And Programming Language ? Then DonateWhen You Found The Answer Your Looking For Please Add [Resolved] To The Thread's Name That Will Show Otheres That You Have Found What Your Looking For And They Whount Have To Enter The Thread.

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...