E1M1 Posted January 8, 2010 Share Posted January 8, 2010 1)How to convert process name or window title to PID? 2)How to convert process PID/name to window title? Thanks edited Link to comment Share on other sites More sharing options...
Xenobiologist Posted January 8, 2010 Share Posted January 8, 2010 (edited) 1)How to convert process name or window title to PID? 2)How to convert process PID/name to window title? ProcssExists, Function WinGetProcess expandcollapse popup#include<Array.au3> $a = ProcessGetId('firefox.exe') For $i = 1 To UBound($a) - 1 ConsoleWrite(ProcessGetWindow($a[$i]) & @CRLF) Next Func ProcessGetWindow($PId) If IsNumber($PId) = 0 Or ProcessExists(ProcessGetName($PId)) = 0 Then SetError(1) Else Local $WinList = WinList() Local $i = 1 Local $WindowTitle = "" While $i <= $WinList[0][0] And $WindowTitle = "" If WinGetProcess($WinList[$i][0], "") = $PId Then $WindowTitle = $WinList[$i][0] Else $i += 1 EndIf WEnd Return $WindowTitle EndIf EndFunc ;==>ProcessGetWindow Func ProcessGetId($Process) If IsString($Process) = 0 Then SetError(2) ElseIf ProcessExists($Process) = 0 Then SetError(1) Else Local $PList = ProcessList($Process) Local $i Local $PId[$PList[0][0] + 1] $PId[0] = $PList[0][0] For $i = 1 To $PList[0][0] $PId[$i] = $PList[$i][1] Next Return $PId EndIf EndFunc ;==>ProcessGetId Func ProcessGetName($PId) If IsNumber($PId) = 0 Then SetError(2) ElseIf $PId > 9999 Then SetError(1) Else Local $PList = ProcessList() Local $i = 1 Local $ProcessName = "" While $i <= $PList[0][0] And $ProcessName = "" If $PList[$i][1] = $PId Then $ProcessName = $PList[$i][0] Else $i = $i + 1 EndIf WEnd Return $ProcessName EndIf EndFunc ;==>ProcessGetName [/left] Edited January 8, 2010 by Xenobiologist Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
SkellySoul Posted January 8, 2010 Share Posted January 8, 2010 1)How to convert process name or window title to PID? 2)How to convert process PID/name to window title? ProcssExists, Function WinGetProcess expandcollapse popup#include<Array.au3> $a = ProcessGetId('firefox.exe') For $i = 1 To UBound($a) - 1 ConsoleWrite(ProcessGetWindow($a[$i]) & @CRLF) Next Func ProcessGetWindow($PId) If IsNumber($PId) = 0 Or ProcessExists(ProcessGetName($PId)) = 0 Then SetError(1) Else Local $WinList = WinList() Local $i = 1 Local $WindowTitle = "" While $i <= $WinList[0][0] And $WindowTitle = "" If WinGetProcess($WinList[$i][0], "") = $PId Then $WindowTitle = $WinList[$i][0] Else $i += 1 EndIf WEnd Return $WindowTitle EndIf EndFunc ;==>ProcessGetWindow Func ProcessGetId($Process) If IsString($Process) = 0 Then SetError(2) ElseIf ProcessExists($Process) = 0 Then SetError(1) Else Local $PList = ProcessList($Process) Local $i Local $PId[$PList[0][0] + 1] $PId[0] = $PList[0][0] For $i = 1 To $PList[0][0] $PId[$i] = $PList[$i][1] Next Return $PId EndIf EndFunc ;==>ProcessGetId Func ProcessGetName($PId) If IsNumber($PId) = 0 Then SetError(2) ElseIf $PId > 9999 Then SetError(1) Else Local $PList = ProcessList() Local $i = 1 Local $ProcessName = "" While $i <= $PList[0][0] And $ProcessName = "" If $PList[$i][1] = $PId Then $ProcessName = $PList[$i][0] Else $i = $i + 1 EndIf WEnd Return $ProcessName EndIf EndFunc ;==>ProcessGetName [/left] I was looking for something like this a week ago thanks very much Link to comment Share on other sites More sharing options...
E1M1 Posted January 8, 2010 Author Share Posted January 8, 2010 My Great thanks edited Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now