Sardith Posted March 30, 2007 Share Posted March 30, 2007 Is there any way to make a process list, with process's icon? expandcollapse popup#include <GUIConstants.au3> $hGui = GUICreate("Test", 360, 400, -1, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) $list=GUICtrlCreateList ("", 100,32, 200, 300) GUICtrlSetLimit(-1,200) ; to limit horizontal scrolling GUICtrlSetData(-1, _FormatProcessList()) $Button_1 = GUICtrlCreateButton ("Refresh", 10, 30, 100) GUISetState () Func Refresh() GUICtrlSetData($List, "") GUICtrlSetData($List, _FormatProcessList()) EndFunc Func _FormatProcessList() Local $list = ProcessList() Local $retstr = 0 For $i = 1 To $list[0][0] $retstr = $retstr & $list[$i][0] If $i < $list[0][0] Then $retstr = $retstr & "|" Next Return $retstr EndFunc GUISetState () While 1 $msg = GUIGetMsg(1) Switch $Msg Case $Button_1 Refresh() EndSwitch Wend [font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font] Link to comment Share on other sites More sharing options...
BrettF Posted March 30, 2007 Share Posted March 30, 2007 To get you started: ProcessList() Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Sardith Posted March 30, 2007 Author Share Posted March 30, 2007 Yeah, that happens to be in the first post. Add/Remove Programs Listhttp://www.autoitscript.com/forum/index.ph...mp;#entry140923For some reason smoke, big daddy's program isn't displaying any icons for me. [font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font] Link to comment Share on other sites More sharing options...
Sardith Posted March 30, 2007 Author Share Posted March 30, 2007 Func FileGetIconCount($szFile) Local $nCount = 0 Local $LPCTSTR = DllStructCreate("char[260]") DllStructSetData($LPCTSTR, 1, $szFile) $nCount = DllCall("shell32.dll", "int", "ExtractIconEx", "ptr", DllStructGetPtr($LPCTSTR), "int", -1, "int", 0, "int", 0, "int", 0) Return $nCount[0] EndFunc Func FileGetIcon(ByRef $szIconFile, ByRef $nIcon, $szFile) Local $szRegDefault = "", $szDefIcon = "" $nIcon = 0 $szExt = StringRight($szFile,4) $szRegDefault = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $szExt,"ProgID") If $szRegDefault = "" Then $szRegDefault = RegRead("HKCR\" & $szExt,"") If $szRegDefault <> "" Then $szDefIcon = RegRead("HKCR\" & $szRegDefault & "\DefaultIcon","") If $szDefIcon = "" Then $szIconFile = "shell32.dll" ElseIf $szDefIcon <> "%1" Then $arSplit = StringSplit($szDefIcon,",") If IsArray($arSplit) Then $szIconFile = $arSplit[1] If $arSplit[0] > 1 Then $nIcon = $arSplit[2] Else Return 0 EndIf EndIf Return 1 EndFunc Could anyone help me out with this funcation, found via search. FileGetIcon(ByRef $szIconFile, ByRef $nIcon, $szFile). Wanted to test it, but im not sure how to test it. [font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font] Link to comment Share on other sites More sharing options...
BrettF Posted March 30, 2007 Share Posted March 30, 2007 My Bad! Sorry! :"> Ok. I'm Seeing how the function works... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
BrettF Posted March 30, 2007 Share Posted March 30, 2007 (edited) My Bad! Sorry! :"> Ok. I'm Seeing how the function works...Did you get the functions from this topic? Edited March 30, 2007 by bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Sardith Posted March 31, 2007 Author Share Posted March 31, 2007 Correct. [font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font] Link to comment Share on other sites More sharing options...
Sardith Posted April 2, 2007 Author Share Posted April 2, 2007 Anyone have any ideas of how to go about doing this? [font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font] Link to comment Share on other sites More sharing options...
Sardith Posted May 3, 2007 Author Share Posted May 3, 2007 Still to no avail. I was looking at this code, if someone can help me edit it a bit. Im no good at taking apart others work. expandcollapse popup; AutoIt Version: 3.1.1.70 (min) ; Author: Holger Kotsch ; ; Script Function: ; IconFileScanner 1.2 ; ; ---------------------------------------------------------------------------- #include <GUIConstants.au3> If Not IsDeclared("LVM_SETCOLUMN") Then Global Const $LVM_SETCOLUMN = 0x101A Global Const $LVM_GETITEM = $LVM_FIRST + 5 Global $arIconFiles[1000] Global $szDirType = RegRead("HKCR\Directory", "") If $szDirType = "" Then $szDirType = "Directory" Global $nFirstEntry = 0, $nLastEntry = 0 Global $szCurrentPath = @WindowsDir Global $szVersion = "1.3" Global $nCurCol = -1 Global $nSortDir = 1 Global $bSet = 0 Global $nCol = -1 $hGUI = GUICreate("Icon File Scanner", 585, 342, -1, -1, BitOr($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU)) $nFileMenu = GUICtrlCreateMenu("&File") $nFileSelFolder = GUICtrlCreateMenuItem("Select Folder...",$nFileMenu) $nViewMenu = GUICtrlCreateMenu("&View") $nViewMenuItem0 = GUICtrlCreateMenuItem("Icons", $nViewMenu, -1, 1) $nViewMenuItem1 = GUICtrlCreateMenuItem("Report", $nViewMenu, -1, 1) GUICtrlSetState(-1, $GUI_CHECKED) $nViewMenuItem2 = GUICtrlCreateMenuItem("SmallIcons", $nViewMenu,-1, 1) $nViewMenuItem3 = GUICtrlCreateMenuItem("List", $nViewMenu, -1, 1) $nHelpMenu = GUICtrlCreateMenu("&Help") $nAboutItem = GUICtrlCreateMenuItem("About",$nHelpMenu) GUICtrlCreateLabel("", 0, 0, 701, 2, $SS_SUNKEN) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKHEIGHT) $nPathLabel = GUICtrlCreateLabel("Path:",5, 5, 30, 18) GUICtrlSetResizing(-1, $GUI_DOCKALL) $nCurPath = GUICtrlCreateCombo($szCurrentPath, 35, 2, 350, 20) GUICtrlSetResizing(-1, $GUI_DOCKALL) $nGoButton= GUICtrlCreateButton("Go", 385, 2, 25, 20, $BS_FLAT) GUICtrlSetState(-1, $GUI_DEFBUTTON) GUICtrlSetResizing(-1, $GUI_DOCKALL) $nPathButton= GUICtrlCreateButton("...", 410, 2, 25, 20, BitOr($BS_ICON, $BS_FLAT)) GUICtrlSetImage(-1, "shell32.dll", 3, 0) GUICtrlSetResizing(-1, $GUI_DOCKALL) $nDirList = GUICtrlCreateListView("Name|Size|Type|Changed", 0, 23, 390, 280) GUICtrlRegisterListViewSort(-1, "LVSort") GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKBOTTOM) GUICtrlSendMsg(-1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlListViewSetColumnFormat($nDirList, 1, $LVCFMT_RIGHT) GUICtrlSetImage(-1, "shell32.dll", 0) $nContext = GUICtrlCreateContextMenu($nDirList) $viewitem = GUICtrlCreateMenu("View", $nContext) GUICtrlCreateMenuItem("",$nContext) $nInfoItem = GUICtrlCreateMenuItem("Info", $nContext) $nDirItem0 = GUICtrlCreateMenuItem("Icons", $viewitem, -1, 1) $nDirItem1 = GUICtrlCreateMenuItem("Report", $viewitem, -1, 1) GUICtrlSetState(-1, $GUI_CHECKED) $nDirItem2 = GUICtrlCreateMenuItem("SmallIcons", $viewitem,-1, 1) $nDirItem3 = GUICtrlCreateMenuItem("List", $viewitem, -1, 1) $nIconList = GUICtrlCreateListView("Icon", 395, 23, 190, 280) GUICtrlSetStyle(-1, BitOr($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $WS_TABSTOP)) ; set this ListView to LVS_ICON-style cause LVS_ICON = 0x0000 GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKBOTTOM) $nIconMenu = GUICtrlCreateContextMenu($nIconList) $nIconItem0 = GUICtrlCreateMenuItem("Icons", $nIconMenu, -1, 1) GUICtrlSetState(-1, $GUI_CHECKED) $nIconItem1 = GUICtrlCreateMenuItem("Report", $nIconMenu, -1, 1) $nIconItem2 = GUICtrlCreateMenuItem("SmallIcons", $nIconMenu,-1, 1) $nIconItem3 = GUICtrlCreateMenuItem("List", $nIconMenu, -1, 1) $nFileInfo = GUICtrlCreateLabel("File:", 0, 305, 390, 18, $SS_SUNKEN) GUICtrlSetResizing(-1, $GUI_DOCKHEIGHT) $nIconInfo = GUICtrlCreateLabel("Icons:", 395, 305, 190, 18, $SS_SUNKEN) GUICtrlSetResizing(-1, $GUI_DOCKHEIGHT) GUISetState() $nFirstItem = 0 $nLastItem = 0 $nFirstIcon = 0 $nLastIcon = 0 $nOldItem = 0 DirToList($szCurrentPath) GUICtrlSendMsg($nDirList, $LVM_SETCOLUMNWIDTH, 0, -1) GUICtrlSendMsg($nDirList, $LVM_SETCOLUMNWIDTH, 0, -2) While 1 $nMsg = GUIGetMsg () Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_RESIZED GUISetState(@SW_LOCK, $hGUI) $nStyle = DllCall("user32.dll", "int", "GetWindowLong", "hwnd", GUICtrlGetHandle($nIconList), "int", -16) $nStyle = BitAnd($nStyle[0], 0x0003) GUICtrlSetStyle($nIconList, BitOr(1, $LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $WS_TABSTOP)) GUICtrlSetStyle($nIconList, BitOr($nStyle, $LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $WS_TABSTOP)) GUISetState(@SW_UNLOCK, $hGUI) Case $nAboutItem, $nInfoItem Msgbox(0 ,"About", "IconFileScanner " & $szVersion & " by Holger Kotsch") Case $nPathButton, $nFileSelFolder, $nGoButton, $nCurPath If $nMsg = $nGoButton Or $nMsg = $nCurPath Then $szFolder = GUICtrlRead($nCurPath) If Not FileExists($szFolder) Then ContinueLoop Else $szFolder = FileSelectFolder("Select folder to scan", "", 0, $szCurrentPath) EndIf If $szFolder <> "" Then $szCurrentPath = $szFolder GUICtrlSetData($nCurPath, $szCurrentPath, $szCurrentPath) GUICtrlSetData($nFileInfo, "Scanning folder...") GUICtrlSetData($nIconInfo, "Icons:") For $i = $nFirstIcon To $nLastIcon GUICtrlDelete($i) Next For $i = $nFirstItem To $nLastItem GUICtrlDelete($i) Next $nFirstItem = 0 $nLastItem = 0 $nFirstIcon = 0 $nLastIcon = 0 $nOldItem = 0 GUISetCursor(1) GUICtrlSetCursor($nDirList,1) DirToList($szCurrentPath) GUISetCursor(2) GUICtrlSetCursor($nDirList,2) EndIf Case $nDirItem0 To $nDirItem3, $nViewMenuItem0 To $nViewMenuItem3 If $nMsg >= $nDirItem0 And $nMsg <= $nDirItem3 Then $nMsgItem = $nDirItem0 For $i = 0 To 3 GUICtrlSetState($nViewMenuItem0 + $i, $GUI_UNCHECKED) Next GUICtrlSetState($nViewMenuItem0 + $nMsg - $nMsgItem, $GUI_CHECKED) Else $nMsgItem = $nViewMenuItem0 For $i = 0 To 3 GUICtrlSetState($nDirItem0 + $i, $GUI_UNCHECKED) Next GUICtrlSetState($nDirItem0 + $nMsg - $nMsgItem, $GUI_CHECKED) EndIf GUICtrlSetStyle($nDirList, BitOr($nMsg - $nMsgItem, $LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $WS_TABSTOP)) If BitAnd($nMsg - $nMsgItem, $LVS_REPORT) Then GUICtrlSendMsg($nDirList, $LVM_SETCOLUMNWIDTH,0,200) For $i = 1 To 3 GUICtrlSendMsg($nDirList, $LVM_SETCOLUMNWIDTH, $i,-1) GUICtrlSendMsg($nDirList, $LVM_SETCOLUMNWIDTH, $i,-2) Next EndIf Case $nIconItem0 To $nIconItem3 GUICtrlSetStyle($nIconList, BitOr($nMsg - $nIconItem0, $LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $WS_TABSTOP)) Case $nFirstItem To $nLastItem If $nMsg <> $nOldItem Then $nOldItem = $nMsg $szFileInfo = StringSplit(GUICtrlRead($nMsg),"|") $szFile = $szFileInfo[1] If $nFirstIcon > 0 Then For $i = $nFirstIcon To $nLastIcon GUICtrlDelete($i) Next EndIf GUICtrlSetData($nFileInfo, "Type: " & $szFileInfo[3] & " Changed at: " & $szFileInfo[4] & " Size: " & $szFileInfo[2]) $nIcons = FileGetIconCount($szCurrentPath & "\" & $szFile) GUICtrlSetData($nIconInfo, "Extracting icons...") GUISetCursor(1) GUICtrlSetCursor($nIconList,1) For $i = 0 To $nIcons - 1 $nIcon = GUICtrlCreateListViewItem($i, $nIconList) GUICtrlSetImage(-1,$szCurrentPath & "\" & $szFile,$i) If $nFirstIcon = 0 Then $nFirstIcon = $nIcon Next GUICtrlSetData($nIconInfo, "Icons: " & $nIcons) GUISetCursor(2) GUICtrlSetCursor($nIconList,2) $nLastIcon = $nIcon EndIf Case $nDirList $bSet = 0 $nCurCol = $nCol GUICtrlSendMsg($nDirList, $LVM_SETSELECTEDCOLUMN, GUICtrlGetState($nDirList), 0) DllCall("user32.dll", "int", "InvalidateRect", "hwnd", GUICtrlGetHandle($nDirList), "int", 0, "int", 1) EndSwitch WEnd Exit Func FileGetIconCount($szFile) Local $nCount = 0 Local $LPCTSTR = DllStructCreate("char[260]") DllStructSetData($LPCTSTR, 1, $szFile) $nCount = DllCall("shell32.dll", "int", "ExtractIconEx", "ptr", DllStructGetPtr($LPCTSTR), "int", -1, "int", 0, "int", 0, "int", 0) Return $nCount[0] EndFunc Func DirToList($szPath) Local $hSearch, $szFile, $szDate, $szType, $nItem $hSearch = FileFindFirstFile($szPath & "\*.*") If $hSearch <> -1 Then $nItem = -1 While 1 $szFile = FileFindNextFile($hSearch) If @error Then ExitLoop If $szFile <> "." And $szFile <> ".." And Not StringInStr(FileGetAttrib($szPath & "\" & $szFile),"D") Then $szExt = ".ani|.cpl|.ico|.icl|.dll|.exe" $szExt = StringSplit($szExt,"|") $nExtFound = 0 For $i = 1 To $szExt[0] If StringInStr($szFile, $szExt[$i]) Then $nExtFound = 1 ExitLoop EndIf Next If $nExtFound Then $nIcon = 0 $szIconFile = $szPath & "\" & $szFile If FileGetIconCount($szIconFile) > 0 Then If FileGetIcon($szIconFile, $nIcon, $szFile) Then $szSize = Round(FileGetSize($szPath & "\" & $szFile) / 1000) & " KB" $szType = FileGetType($szFile) $arDate = FileGetTime($szPath & "\" & $szFile) If IsArray($arDate) Then $szDate = $arDate[2] & "." & $arDate[1] & "." & $arDate[0] & " " & $arDate[3] & ":" & $arDate[4] $nItem = GUICtrlCreateListViewItem($szFile & "|" & $szSize & "|" & $szType & "|" & $szDate, $nDirList) GUICtrlSetImage(-1,$szIconFile,$nIcon) If $nFirstItem = 0 Then $nFirstItem = $nItem EndIf EndIf EndIf EndIf WEnd FileClose($hSearch) $nLastItem = $nItem If $nLastItem > 0 Then GUICtrlSetData($nFileInfo, $nLastItem - $nFirstItem & " Objects") Else GUICtrlSetData($nFileInfo, "Ready") EndIf EndIf EndFunc Func FileGetType($szFile) Local $szRegDefault = "", $szRegType = "" $szExt = StringRight($szFile,4) $szRegDefault = RegRead("HKCR\" & $szExt,"") If $szRegDefault <> "" Then $szRegType = RegRead("HKCR\" & $szRegDefault,"") If $szRegType = "" Then $szRegType = $szExt & "-File" Return $szRegType EndFunc Func FileGetIcon(ByRef $szIconFile, ByRef $nIcon, $szFile) Local $szRegDefault = "", $szDefIcon = "" $nIcon = 0 $szExt = StringRight($szFile,4) $szRegDefault = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $szExt,"ProgID") If $szRegDefault = "" Then $szRegDefault = RegRead("HKCR\" & $szExt,"") If $szRegDefault <> "" Then $szDefIcon = RegRead("HKCR\" & $szRegDefault & "\DefaultIcon","") If $szDefIcon = "" Then $szIconFile = "shell32.dll" ElseIf $szDefIcon <> "%1" Then $arSplit = StringSplit($szDefIcon,",") If IsArray($arSplit) Then $szIconFile = $arSplit[1] If $arSplit[0] > 1 Then $nIcon = $arSplit[2] Else Return 0 EndIf EndIf Return 1 EndFunc Func GUICtrlListViewSetColumnFormat($hListView, $nCol, $nFormat) $hListViewHeader = GUICtrlSendMsg($hListView, $LVM_GETHEADER, 0, 0) Local $LVCOLUMN = DllStructCreate("uint;int;int;ptr;int;int;int;int") DllStructSetData($LVCOLUMN, 1, $LVCF_FMT) DllStructSetData($LVCOLUMN, 2, $nFormat) GUICtrlSendMsg($hListView, $LVM_SETCOLUMN, $nCol, DllStructGetPtr($LVCOLUMN)) EndFunc Func LVSort($hWnd, $nItem1, $nItem2, $nColumn) Local $nSort GUICtrlSetCursor($nDirList, 1) If $nColumn = $nCurCol Then If Not $bSet Then $nSortDir = $nSortDir * -1 $bSet = 1 EndIf Else $nSortDir = 1 EndIf $nCol = $nColumn $val1 = GetSubItemText($nDirList, $nItem1, $nColumn) $val2 = GetSubItemText($nDirList, $nItem2, $nColumn) If $nColumn = 1 Then $val1 = Number(StringTrimRight($val1, 3)) $val2 = Number(StringTrimRight($val2, 3)) ElseIf $nColumn = 3 Then $val1 = StringRight(StringTrimRight($val1, 6), 4) & StringMid($val1, 4, 2) & StringLeft($val1, 2) $val2 = StringRight(StringTrimRight($val2, 6), 4) & StringMid($val2, 4, 2) & StringLeft($val2, 2) EndIf $nResult = 0 If $val1 < $val2 Then $nResult = -1 ElseIf $val1 > $val2 Then $nResult = 1 EndIf $nResult = $nResult * $nSortDir GUICtrlSetCursor($nDirList, 2) Return $nResult EndFunc Func GetSubItemText($nCtrlID, $nItemID, $nColumn) Local $stLvfi = DllStructCreate("uint;ptr;int;int[2];int") DllStructSetData($stLvfi, 1, $LVFI_PARAM) DllStructSetData($stLvfi, 3, $nItemID) Local $stBuffer = DllStructCreate("char[260]") $nIndex = GUICtrlSendMsg($nCtrlID, $LVM_FINDITEM, -1, DllStructGetPtr($stLvfi)); Local $stLvi = DllStructCreate("uint;int;int;uint;uint;ptr;int;int;int;int") DllStructSetData($stLvi, 1, $LVIF_TEXT) DllStructSetData($stLvi, 2, $nIndex) DllStructSetData($stLvi, 3, $nColumn) DllStructSetData($stLvi, 6, DllStructGetPtr($stBuffer)) DllStructSetData($stLvi, 7, 260) GUICtrlSendMsg($nCtrlID, $LVM_GETITEM, 0, DllStructGetPtr($stLvi)); Return DllStructGetData($stBuffer, 1) EndFunc Pretty much just need the name field. Any help would be great. [font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font] 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