MadaraUchiha Posted October 31, 2013 Share Posted October 31, 2013 Yo, I like to list the Processname, PID and Executable Path in a ListView. For the first two (name & PID) I can use ProcessList() Function, and for the Path I use thiese DLL Calls: Func _ProcessGetLocation($iPID) Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID) If $aProc[0] = 0 Then Return SetError(1, 0, '') Local $vStruct = DllStructCreate('int[1024]') DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 0) Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048) If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '') Return $aReturn[3] EndFunc So I like to list them, like this: #include <GuiConstants.au3> Func _ProcessGetLocation($iPID) Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID) If $aProc[0] = 0 Then Return SetError(1, 0, '') Local $vStruct = DllStructCreate('int[1024]') DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 0) Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048) If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '') Return $aReturn[3] EndFunc Dim $Table, $list,$test GuiCreate("Processes", 300, 400, 200,200) $Table = GuiCtrlCreateListView ('Process Name | Pid|Path',10,10,280,380) $list = ProcessList() for $i = 1 to $list[0][0] GuiCtrlCreateListViewItem($list[$i][0] & ' | ' & $list[$i][1],$Table) For $test = 1 to $list[0][1] GuiCtrlCreateListViewItem($list[$i][0] & ' | ' & $list[$i][1] $ ' | ' & _ProcessGetLocation($list[$i][1]),$Table) Next next GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd But it says: syntax error: illegal character? This error occurs in this line: GuiCtrlCreateListViewItem($list[$i][0] & ' | ' & $list[$i][1] $ ' | ' & _ProcessGetLocation($list[$i][1]),$Table) How can I fix this? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 31, 2013 Moderators Share Posted October 31, 2013 MadaraUchiha,Look at these:; Original - error GuiCtrlCreateListViewItem($list[$i][0] & ' | ' & $list[$i][1] $ ' | ' & _ProcessGetLocation($list[$i][1]),$Table) ; Altered - no error GuiCtrlCreateListViewItem($list[$i][0] & ' | ' & $list[$i][1] & ' | ' & _ProcessGetLocation($list[$i][1]),$Table)Can you see the difference? If you still cannot see it: Look for a $/& mismatchM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MadaraUchiha Posted October 31, 2013 Author Share Posted October 31, 2013 Oh really, it was a & $ missmatch... Thanks... Fixed it now, but the third column of my ListView stays empty anyways...? #include <GuiConstants.au3> Func _ProcessGetLocation($iPID) Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID) If $aProc[0] = 0 Then Return SetError(1, 0, '') Local $vStruct = DllStructCreate('int[1024]') DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 0) Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048) If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '') Return $aReturn[3] EndFunc Dim $Table, $list,$test GuiCreate("Processes", 300, 400, 200,200) $Table = GuiCtrlCreateListView ('Process Name | Pid|Path',10,10,280,380) $list = ProcessList() for $i = 1 to $list[0][0] GuiCtrlCreateListViewItem($list[$i][0] & ' | ' & $list[$i][1],$Table) For $test = 1 to $list[0][1] GuiCtrlCreateListViewItem($list[$i][0] & ' | ' & $list[$i][1] & ' | ' & _ProcessGetLocation($list[$i][1]),$Table) Next next GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd I am kinda confused, because I have three columns, and normally it should fill all three, shouldn't it? I have first for name, second for PID and third for Path. But for some reason the Path won't popup in the third column? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 31, 2013 Moderators Share Posted October 31, 2013 MadaraUchiha,What was the internal $test loop doing in your ListView creation code? As the upper limit was always 0 it never ran and so the only item that was entered into the ListView (by the outer loop) did not have a path element. This amended loop works for me:For $i = 1 To $list[0][0] ;GuiCtrlCreateListViewItem($list[$i][0] & ' | ' & $list[$i][1], $Table) ;For $test = 1 to $list[0][1] $sPath = _ProcessGetLocation($list[$i][1]) If Not @error Then ; Why bother to return an error if you do not check for it? GUICtrlCreateListViewItem($list[$i][0] & ' | ' & $list[$i][1] & ' | ' & $sPath, $Table) EndIf ;Next NextDoes it work for you too? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MadaraUchiha Posted October 31, 2013 Author Share Posted October 31, 2013 (edited) Yes Thats already a good jump into the right direction, thnaks so far.^^But, some processpath's got a bit... uh... messed up: It's displaying garbage Text like Ä or Ľ.Can I replace this with a clear N/A instead of this ? Edited October 31, 2013 by Melba23 Removed profanity Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 31, 2013 Moderators Share Posted October 31, 2013 MadaraUchiha,I suggest you check whether the returned path has ":" as the second and third characters (StringMid will help here) and if it does not then you replace the string with "N/A". M23P.S. And there is no need to use such language when you post. MadaraUchiha 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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