funkey Posted June 1, 2010 Share Posted June 1, 2010 (edited) expandcollapse popup#Include <Array.au3> Global $array $array = _ProcessGetWin("explorer.exe") _ArrayDisplay($array, '_ProcessGetWin - All') $array = _ProcessGetWin("explorer.exe", 0) _ArrayDisplay($array, '_ProcessGetWin - Titles') $array = _ProcessGetWin("explorer.exe", 1) _ArrayDisplay($array, '_ProcessGetWin - Handles') $array = _ProcessGetWin("explorer.exe", 2) _ArrayDisplay($array, '_ProcessGetWin - Classes') ; #FUNCTION# ==================================================================================================================== ; Name...........: _ProcessGetWin ; Description ...: Returns a list of ALL window titles and/or window handles belonging to the given Process ID. ; Syntax.........: _ProcessGetWin($iPID [, $iOption = -1]) ; Parameters ....: $iPID - Numeric Process ID. Default (0) is the current process. ; $iOption - Return window titles AND / OR window handles ; 0 - window titles are returned (1D-array) ; 1 - window handles are returned (1D-array) ; 2 - window classes are returned (1D-array) ; other (Default) - window titles, handles AND classes are returned (2D-array) ; Return values .: Success - Returns an array with all window titles, handles and classes belonging to the given PID (depending on $iOption) ; Failure - Returns @error = 1 if process does not exist ; Author ........: funkey <funkey80 at hotmail dot com> ; Remarks .......: $aHWnd[0] / $aHWnd[0][0] contains the number of windows found ; Related .......: ; Link ..........: ; Example .......: _ProcessGetWin("explorer.exe") ; =============================================================================================================================== Func _ProcessGetWin($iPID = 0, $iOption = -1) Local $aList = WinList(), $aTemp If Not $iPID Then $iPID = @AutoItPID $iPID = ProcessExists($iPID) If $iPID = 0 Then Return SetError(1) Switch $iOption Case 0, 1 Local $aHWnd[1] = [0] For $i = 1 To $aList[0][0] If $iPID = WinGetProcess($aList[$i][1]) Then ReDim $aHWnd[$aHWnd[0] + 2] $aHWnd[0] += 1 $aHWnd[$aHWnd[0]] = $aList[$i][$iOption] EndIf Next Case 2 Local $aHWnd[1] = [0] For $i = 1 To $aList[0][0] If $iPID = WinGetProcess($aList[$i][1]) Then ReDim $aHWnd[$aHWnd[0] + 2] $aHWnd[0] += 1 $aTemp = DllCall("user32.dll", "int", "GetClassNameW", "hwnd", $aList[$i][1], "wstr", "", "int", 4096) $aHWnd[$aHWnd[0]] = $aTemp[2] EndIf Next Case Else Local $aHWnd[1][3] = [[0]] For $i = 1 To $aList[0][0] If $iPID = WinGetProcess($aList[$i][1]) Then ReDim $aHWnd[$aHWnd[0][0] + 2][3] $aHWnd[0][0] += 1 $aHWnd[$aHWnd[0][0]][0] = $aList[$i][0] $aHWnd[$aHWnd[0][0]][1] = $aList[$i][1] $aTemp = DllCall("user32.dll", "int", "GetClassNameW", "hwnd", $aList[$i][1], "wstr", "", "int", 4096) $aHWnd[$aHWnd[0][0]][2] = $aTemp[2] EndIf Next EndSwitch Return $aHWnd EndFunc ;==>_ProcessGetWin Edit: Fixed a little bug. Edited June 3, 2010 by funkey Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
UEZ Posted June 2, 2010 Share Posted June 2, 2010 (edited) Hi funkey, I'm getting 3 times [0] 0 back! Vista x32 BR, UEZ Edited June 2, 2010 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Yashied Posted June 2, 2010 Share Posted June 2, 2010 Look at _WinAPI_EnumProcessWindows() from WinAPIEx.au3. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
funkey Posted June 2, 2010 Author Share Posted June 2, 2010 (edited) Thanks Yashied for showing me _WinAPI_EnumProcessWindows(). So it was easier to find the bug I had. I improved my function to show the window classes too.UEZ, can you please test the new version in post #1. Edited June 2, 2010 by funkey Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
TTQ Posted June 3, 2010 Share Posted June 3, 2010 (edited) Thanks funkey, It worked Edited June 3, 2010 by TTQ Link to comment Share on other sites More sharing options...
UEZ Posted June 3, 2010 Share Posted June 3, 2010 Yep, it is working now! BR, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ 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