Iuli Posted January 13, 2009 Share Posted January 13, 2009 (edited) Hello,This is my first UDF. I thought it may be useful, because i use it very often in my scripts Code :expandcollapse popup;Includes #include <Process.au3> #Include <Array.au3> ;=============================================================================== ; ; Function Name: _ProcessGetWinTitle () ; Description: Gets all windowss associated with a process in a unidimensional array ; Parameter(s): $sProcessName - Name of the process ("Explorer.exe", for instance) ; $iVisibility - Parameter used to check for visible/invisible windowss ; 0 - Check only visible windowss ; 1 - Check for every Window asociated to the specified process ; Requirement(s): <Process.au3> and <Array.au3> are required ; Return Value(s): Success : The array containing the windows name ; Failure : 0 ; Author(s): Iuli ;=============================================================================== Func _ProcessGetWinTitle($sProcessName,$iVisibility) Local $iK, $WinArray[1] $aWinList=WinList () For $iK=1 To $aWinList[0][0] If $iVisibility=0 Then If (_ProcessGetName(WinGetProcess($aWinList[$iK][0]))=$sProcessName) And (_IsVisible($aWinList[$iK][0])) Then _ArrayAdd($WinArray,$aWinList[$iK][0]) EndIf ElseIf $iVisibility=1 Then If _ProcessGetName(WinGetProcess($aWinList[$iK][0]))=$sProcessName Then _ArrayAdd($WinArray,$aWinList[$iK][0]) EndIf EndIf Next Return $WinArray EndFunc ; =================================================================================================== ; Internal Functions from this point on ; =================================================================================================== Func _IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFuncDownload : _ProcessGetWinTitle.au3Enjoy ! Criticism and suggestions are welcomed ! Edited January 13, 2009 by Iuli [size="2"]SFXMaker[/size] - The most complete switchless installer creator software[indent][/indent] Link to comment Share on other sites More sharing options...
wraithdu Posted January 13, 2009 Share Posted January 13, 2009 (edited) Here's an alternative that may be faster. It's a polite process close function that sends the WM_CLOSE messsage to all top level windows of a given process. Same basic idea - Func _CloseProcess_Polite($proc) Local $tpid, $array $tpid = ProcessExists($proc) If $tpid == 0 Then Return $array = WinList() ; $array[n][1]=hwnd of all top-level windows For $i = 1 To $array[0][0] ; # of windows returned ; pid of process that owns window If WinGetProcess($array[$i][1]) == $tpid Then ; window is owned by target process WinClose($array[$i][1]) EndIf Next EndFunc Edited January 13, 2009 by wraithdu Link to comment Share on other sites More sharing options...
FireFox Posted January 13, 2009 Share Posted January 13, 2009 (edited) $WL = WinList() For $nb = 1 to $WL[0][0] $wgp = WinGetProcess($WL[$nb][1]) TrayTip("Window & PID",$WL[$nb][1] & ' = ' & $wgp, 0, 1) Sleep(250) Next if you dont like pid then use _processgetname (udf) or _processlistproperties (udf) Edit : oops didnt seen script from wraithdu Cheers, FireFox. Edited January 13, 2009 by FireFox 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