Jump to content

Zohran

Active Members
  • Posts

    32
  • Joined

  • Last visited

Everything posted by Zohran

  1. Excellent work,indeed hard work, 5 stars indeed.
  2. Hmmmm. Well i want this function because i am going to update my advanced icon displayer.Because if load icons of size 128x128 or greater size for items greater than 500 it consumes much memory.
  3. This is confusing.
  4. Yes. Your Right
  5. thank you. Not very accurate.Its a good effort.
  6. oops, sorry my mistake
  7. Dear Melba It is not working for icon view.
  8. Hi. How to get indices of items in a listview which are currently visible on the screen, not all items?
  9. Not So Easy but Works Nicely.
  10. Looks Like There is no soluton to it in autoit.
  11. still not working. ok . let me clarify more . when we use a fps (frames per second utilty) we can see the frames on our screen . it is displaying on top of every window. just like that i want my gui to be displayed on top of every window
  12. hey is there no one out there for the solution????
  13. high. the problem is that i have crated a gui window with attribute set to $WS_EX_TOPMOST. but when i start a game it remains on back.??? #include <WinAPI.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <_PDH_PerformanceCounters.au3> Global Const $iRadius = 8 Global Const $iOpacity = 200 Global Const $AC_SRC_ALPHA = 0 Global $sString = "",$timer,$hGUI Global Enum $eScrDC = 0, $eMemDC, $eBitmap, $eWidth, $eHeight, $eGraphic, $eLast Global $hPDHQuery, $aCPUCounters, $iTotalCPUs _GDIPlus_Startup() $hCPU = GUICreate("786",$iRadius*110,$iRadius*2, 0,0,0, BitOR($WS_EX_TOOLWINDOW,$WS_EX_LAYERED, $WS_EX_TOPMOST)) GUISetState() $hGraphic = ResourceInit($iRadius*110,$iRadius*2) $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFF2F) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily,10,0) $tLayout = _GDIPlus_RectFCreate(0, 0, $iRadius * 110,$iRadius*2 ) _PDH_Init() $hPDHQuery = _PDH_GetNewQueryHandle() $aCPUCounters = _PDH_GetCPUCounters($hPDHQuery, "") $iTotalCPUs = @extended Func ResourceInit($iWidth, $iHeight) Local $aInfo[$eLast + 1] $aInfo[$eScrDC] = _WinAPI_GetDC(0) $aInfo[$eMemDC] = _WinAPI_CreateCompatibleDC($aInfo[$eScrDC]) $aInfo[$eBitmap] = _WinAPI_CreateCompatibleBitmap($aInfo[$eScrDC], $iWidth, $iHeight) _WinAPI_SelectObject($aInfo[$eMemDC], $aInfo[$eBitmap]) $aInfo[$eWidth] = $iWidth $aInfo[$eHeight] = $iHeight $aInfo[$eGraphic] = _GDIPlus_GraphicsCreateFromHDC($aInfo[$eMemDC]) _GDIPlus_GraphicsFillRect($aInfo[$eGraphic], 0, 0, $iRadius * 110, $iRadius * 2) Return $aInfo EndFunc ;==>ResourceInit Func ResourceSet($hGUI, ByRef $aInfo, $iAlpha = -1) Local $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend If $iAlpha = -1 Then $iAlpha = $iOpacity $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $aInfo[$eWidth]) DllStructSetData($tSize, "Y", $aInfo[$eHeight]) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iAlpha) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $aInfo[$eScrDC], 0, $pSize, $aInfo[$eMemDC], $pSource, 0, $pBlend, $ULW_ALPHA) EndFunc ;==>ResourceSet While 1 = 1 Sleep(1000) _PDH_CollectQueryData($hPDHQuery) $iCounterValue = _PDH_UpdateCounter($hPDHQuery, $aCPUCounters[$iTotalCPUs - 1][1], 0, True) $mem = MemGetStats() $sString = "CPU:" & $iCounterValue & "%" & " ,Memory Load: " & $mem[0] & "% ,GPU TEMP/LOAD:" & ControlGetText("TechPowerUp GPU-Z 0.6.2","","Static73") & "/ " & ControlGetText("TechPowerUp GPU-Z 0.6.2","","Static82") & ",GCC:" & ControlGetText("TechPowerUp GPU-Z 0.6.2","","Static67") & ",GMC:" & ControlGetText("TechPowerUp GPU-Z 0.6.2","","Static70") & ",Dedicated:" & ControlGetText("TechPowerUp GPU-Z 0.6.2","","Static88") & ",Dynamic:" & ControlGetText("TechPowerUp GPU-Z 0.6.2","","Static91") $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic[$eGraphic], $sString, $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsFillRect($hGraphic[$eGraphic], 0, 0, $iRadius * 110, $iRadius * 2) _GDIPlus_GraphicsDrawStringEx($hGraphic[$eGraphic], $sString, $hFont, $aInfo[0], $hFormat, $hBrush) ResourceSet($hCPU, $hGraphic) WEnd Func _PDH_GetCPUCounters($hPDHQuery, $sPCName = "") If $sPCName <> "" And StringLeft($sPCName, 2) = "" Then $sPCName = StringTrimLeft($sPCName, 1) Local $aCPUsList = _PDH_GetCounterList(":2386(*)" & $sPCName) If @error Then Return SetError(@error, @extended, "") Local $aCPUCounters = _PDH_AddCountersByArray($hPDHQuery, $aCPUsList, 1, -1) If @error Then Return SetError(@error, @extended, "") Return SetExtended($aCPUsList[0], $aCPUCounters) EndFunc ;==>_PDH_GetCPUCounters
  14. Above Program Updated.
  15. sure. no problem
  16. thanks.just a little update in above code.updated
  17. Displays Correct Icons up to the max. some extra features added. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <APIConstants.au3> #include <File.au3> #include <WinAPIEx.au3> #include <GuiImageList.au3> #include <AutoItObject.au3> #include <GDIPlus.au3> Opt("GUIOnEventMode", 1) Global $FileList, $FolderList Global $iCX = 32, $iCY = 32 ;icon size Global $progressbar1, $attributes Global $Inputtext = "", $oldtip = "" Global $EnterKey ; gui accel key Global $FolderIconIndex = 1 Global $FileIconIndex = 1 Global $folderIconsDone = False Global $EnterPressed = False Global $DestroyImageList = False Global $ListViewPopulate = False Global $AddIconOverlay = False Global $hGraphics1, $hIcon, $hOverlay Global $ResourceFile, $overlayindex, $hPen Global $IShellItemImageFactoryIsInterfaceAvailable = False Global Const $tagICOHEADER = 'ushort Reserved;ushort Type;ushort Count' Global Const $tagICOENTRY = 'byte Width;byte Height;byte ColorCount;byte Reserved;ushort Planes;ushort BitCount;long Size;long Offset' Global Const $tagIHDR = 'dword Width;dword Height;byte BitDepth;byte ColorType;byte CompressionMethod;byte FilterMethod;byte InterlaceMethod' Global Const $sIID_IShellItemImageFactory = "{bcc18b79-ba16-442f-80c4-8a59c30c463b}" Global Const $dtagIShellItemImageFactory = $dtagIUnknown & "GetImage hresult(uint64;dword;ptr*);" $sIID_IShellFolder = "{000214E6-0000-0000-C000-000000000046}" Global Const $dtagIShellFolder = $dtagIUnknown & _ "ParseDisplayName hresult(hwnd;ptr;wstr;dword*;ptr*;dword*);" & _ "EnumObjects hresult(hwnd;dword;ptr*);" & _ "BindToObject hresult(ptr;ptr;ptr;ptr*);" & _ "BindToStorage hresult(ptr;ptr;ptr;ptr*);" & _ "CompareIDs hresult(lparam;ptr;ptr);" & _ "CreateViewObject hresult(hwnd;ptr;ptr*);" & _ "GetAttributesOf hresult(UINT;ptr;ulong*);" & _ "GetUIObjectOf hresult(hwnd;uint;ptr;ptr;uint*;ptr*);" & _ "GetDisplayNameOf hresult(ptr;uint;ptr);" & _ "SetNameOf hresult(hwnd;ptr;wstr;dword;ptr*);" Global Const $ltagIShellFolder = $ltagIUnknown & _ "ParseDisplayName;" & _ "EnumObjects;" & _ "BindToObject;" & _ "BindToStorage;" & _ "CompareIDs;" & _ "CreateViewObject;" & _ "GetAttributesOf;" & _ "GetUIObjectOf;" & _ "GetDisplayNameOf;" & _ "SetNameOf;" Global Const $sIID_IExtractImage = "{BB2E617C-0920-11d1-9A0B-00C04FC2D6C1}" Global Const $dtagIExtractImage = $dtagIUnknown & _ "GetLocation hresult(wstr;DWORD;DWORD*;ptr;dword;DWORD*);" & _ "Extract hresult(ptr*);" Global Const $ltagIExtractImage = $ltagIUnknown & _ "GetLocation;" & _ "Extract;" Global Const $IID_IShellItem = "{43826d1e-e718-42ee-bc55-a1e261c37bfe}" Global Const $dtagIShellItem = $dtagIUnknown & _ "BindToHandler hresult(ptr;ptr;ptr;ptr*);" & _ "GetParent hresult(ptr*);" & _ "GetDisplayName hresult(dword;ptr*);" & _ "GetAttributes hresult(dword;dword*);" & _ "Compare hresult(ptr;dword;int*);" Global Const $ltagIShellItem = $ltagIUnknown & _ "BindToHandler;" & _ "GetParent;" & _ "GetDisplayName;" & _ "GetAttributes;" & _ "Compare;" _AutoItObject_StartUp() If _WinAPI_GetVersion() >= '6.0' Then $ResourceFile = @SystemDir & 'imageres.dll' $overlayindex = 154 $noiconindex = 2 $noiconexeindex = -15 $IShellItemImageFactoryIsInterfaceAvailable = True Global Const $tIIDImgFact = _AutoItObject_CLSIDFromString($sIID_IShellItemImageFactory) Else $ResourceFile = @SystemDir & 'shell32.dll' $overlayindex = 29 $noiconindex = 0 $noiconexeindex = 2 EndIf $Form1_1 = GUICreate("Advanced Listview Icon Display", 801, 616, 192, 124, BitOR($WS_CAPTION, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX)) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1_1Close") $ListView1 = GUICtrlCreateListView("", 8, 64, 785, 545, BitOR($LVS_ICON, $LVS_SHOWSELALWAYS)) _GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT, $LVS_EX_LABELTIP)) $Progress1 = GUICtrlCreateProgress(648, 16, 145, 17) $Radio1 = GUICtrlCreateRadio("16x16 Icons", 16, 16, 90, 17) GUICtrlSetOnEvent($Radio1, "Radio1Click") $Radio2 = GUICtrlCreateRadio("32x32 Icons", 112, 16, 97, 17) GUICtrlSetOnEvent($Radio2, "Radio2Click") GUICtrlSetState($Radio2, 1) $Radio3 = GUICtrlCreateRadio("48x48 Icons", 212, 17, 105, 17) GUICtrlSetOnEvent($Radio3, "Radio3Click") $Radio4 = GUICtrlCreateRadio("64x64 Icons", 323, 17, 97, 17) GUICtrlSetOnEvent($Radio4, "Radio4Click") $Radio5 = GUICtrlCreateRadio("128x128 Icons", 427, 17, 89, 17) GUICtrlSetOnEvent($Radio5, "Radio5Click") $Radio6 = GUICtrlCreateRadio("256x256 Icons", 542, 17, 105, 17) GUICtrlSetOnEvent($Radio6, "Radio6Click") $Inputtext = @ComputerName $Input1 = GUICtrlCreateInput("", 100, 40, 693, 21) $Button1 = GUICtrlCreateButton("Go -->", 50, 40, 41, 21) GUICtrlSetOnEvent($Button1, "Button1Click") $Button2 = GUICtrlCreateButton("Up", 8, 40, 41, 21) GUICtrlSetOnEvent($Button2, "Button2Click") $EnterKey = GUICtrlCreateDummy() GUICtrlSetOnEvent($EnterKey, "_AccelKeys") Dim $AccelKeys[1][2] = [["{ENTER}", $EnterKey]] GUISetAccelerators($AccelKeys) GUICtrlSetState($Input1, $GUI_FOCUS) _GUICtrlListView_SetView($ListView1, 1) $lImage = _GUIImageList_Create($iCX, $iCY, 5, 3) ; by default 32 pixel icon imagelist _GUICtrlListView_SetImageList($ListView1, $lImage, 0) $lImage2 = _GUIImageList_Create($iCX, $iCY, 5, 3) ; by default 32 pixel icon imagelist,create a separate for drives _GUICtrlListView_SetImageList($ListView1, $lImage, 0) drives() Func drives() GUICtrlSetData($Input1, @ComputerName) _GUIImageList_Destroy($lImage2) $lImage2 = _GUIImageList_Create($iCX, $iCY, 5, 3) _GUICtrlListView_SetImageList($ListView1, $lImage2, 0) $drives = DriveGetDrive("ALL") For $x = 1 To $drives[0] Local $tSHFILEINFO = DllStructCreate($tagSHFILEINFO) _WinAPI_ShellGetFileInfo($drives[$x], 0x00001000, 0, $tSHFILEINFO) $hIcon = _WinAPI_ShellExtractIcon(DllStructGetData($tSHFILEINFO, 4), DllStructGetData($tSHFILEINFO, 2), $iCX, $iCX) _GUIImageList_ReplaceIcon($lImage2, -1, $hIcon) _WinAPI_DestroyIcon($hIcon) _GUICtrlListView_AddItem($ListView1, $drives[$x], $x - 1) Next EndFunc ;==>drives $hToolTip = _GUICtrlListView_GetToolTips($ListView1) ; Prevent from displaying original tooltip ,we will create our own _GUICtrlListView_SetToolTips($ListView1, $hToolTip) _GDIPlus_Startup() $hWnd = _WinAPI_GetDesktopWindow() $hDC = _WinAPI_GetDC($hWnd) $hGraphics1 = _GDIPlus_GraphicsCreateFromHDC($hDC) _WinAPI_ReleaseDC($hWnd, $hDC) $hPen = _GDIPlus_PenCreate(0xC6C6C6C6, 3) ;Used for creating a rectangle around icons GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) While 1 Sleep(1) _IconLoad() ; reason to call function in main loop so that our program remains responsive If $EnterPressed == True Then Button1Click() $EnterPressed = False EndIf If $ListViewPopulate == True Then ListViewPopulate($Inputtext) $ListViewPopulate = False EndIf If $DestroyImageList == True Then _GUIImageList_Destroy($lImage) $lImage = _GUIImageList_Create($iCX, $iCY, 5, 3) _GUICtrlListView_SetImageList($ListView1, $lImage, 0) $FolderIconIndex = 1 $FileIconIndex = 1 $folderIconsDone = False $DestroyImageList = False ExtractIconOverlay() EndIf ToolTipEx() WEnd Func _IsPressedBackSpace() Local $a_R = DllCall("user32.dll", "short", "GetAsyncKeyState", "int", '0x08') Return BitAND($a_R[0], 0x8000) <> 0 EndFunc ;==>_IsPressedBackSpace Func Form1_1Close() _AutoItObject_Shutdown() _GDIPlus_PenDispose($hPen) _GDIPlus_Shutdown() Exit EndFunc ;==>Form1_1Close Func _AccelKeys() Switch @GUI_CtrlId Case $EnterKey $EnterPressed = True EndSwitch EndFunc ;==>_AccelKeys Func Button1Click() If FileExists(GUICtrlRead($Input1)) Then $Inputtext = GUICtrlRead($Input1) If (StringMid($Inputtext, StringLen($Inputtext), 1) = "") Then $Inputtext = StringTrimRight($Inputtext, 1) $filefolder = _GUICtrlListView_GetSelectedIndices($ListView1, True) If UBound($filefolder) > 1 And $EnterPressed == True Then $Inputtext = $Inputtext & "" & _GUICtrlListView_GetItemText($ListView1, $filefolder[1]) If Not StringInStr(FileGetAttrib($Inputtext), "D") Then Run(@ComSpec & " /c " & Chr(34) & '"' & $Inputtext & '"' & Chr(34), "", @SW_HIDE) Return EndIf EndIf GUICtrlSetData($Input1, $Inputtext) $ListViewPopulate = True Else $filefolder = _GUICtrlListView_GetSelectedIndices($ListView1, True) If UBound($filefolder) > 1 Then $Inputtext = _GUICtrlListView_GetItemText($ListView1, $filefolder[1]) GUICtrlSetData($Input1, $Inputtext) $ListViewPopulate = True EndIf EndIf EndFunc ;==>Button1Click Func Button2Click() If (StringMid($Inputtext, StringLen($Inputtext), 1) == "") Then $Inputtext = StringTrimRight($Inputtext, 1) $Inputtext = StringLeft($Inputtext, StringInStr($Inputtext, "", 0, -1) - 1) If FileExists($Inputtext) Then GUICtrlSetData($Input1, $Inputtext) $ListViewPopulate = True Else _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1)) $Inputtext = @ComputerName Drives() EndIf EndFunc ;==>Button2Click Func Radio1Click() ;16x16 If $iCX <> 16 Then $iCX = 16 $iCY = 16 If $Inputtext == @ComputerName Then _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1)) Drives() Else $DestroyImageList = True EndIf EndIf EndFunc ;==>Radio1Click Func Radio2Click() ;32x32 If $iCX <> 32 Then $iCX = 32 $iCY = 32 If $Inputtext == @ComputerName Then _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1)) Drives() Else $DestroyImageList = True EndIf EndIf EndFunc ;==>Radio2Click Func Radio3Click() ;48x48 If $iCX <> 48 Then $iCX = 48 $iCY = 48 If $Inputtext == @ComputerName Then _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1)) Drives() Else $DestroyImageList = True EndIf EndIf EndFunc ;==>Radio3Click Func Radio4Click() ;64x64 If $iCX <> 64 Then $iCX = 64 $iCY = 64 If $Inputtext == @ComputerName Then _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1)) Drives() Else $DestroyImageList = True EndIf EndIf EndFunc ;==>Radio4Click Func Radio5Click() ;128x128 If $iCX <> 128 Then $iCX = 128 $iCY = 128 If $Inputtext == @ComputerName Then _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1)) Drives() Else $DestroyImageList = True EndIf EndIf EndFunc ;==>Radio5Click Func Radio6Click() ;256x256 If $iCX <> 256 Then $iCX = 256 $iCY = 256 If $Inputtext == @ComputerName Then _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1)) Drives() Else $DestroyImageList = True EndIf EndIf EndFunc ;==>Radio6Click Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR $hWndListView = ControlGetHandle($hWnd, "", $ListView1) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK $filefolder = _GUICtrlListView_GetSelectedIndices($ListView1, True) If UBound($filefolder) > 1 Then $aitem = _GUICtrlListView_GetItemText($ListView1, $filefolder[1]) If FileExists($Inputtext & "" & $aitem) Then If StringInStr(FileGetAttrib($Inputtext & "" & $aitem), "D") Then $Inputtext = $Inputtext & "" & $aitem GUICtrlSetData($Input1, $Inputtext) $ListViewPopulate = True Else Run(@ComSpec & " /c " & Chr(34) & '"' & $Inputtext & "" & $aitem & '"' & Chr(34), "", @SW_HIDE) EndIf Else If $Inputtext == @ComputerName Then $Inputtext = _GUICtrlListView_GetItemText($ListView1, $filefolder[1]) GUICtrlSetData($Input1, $Inputtext) $ListViewPopulate = True EndIf EndIf EndIf Case $LVN_KEYDOWN If _IsPressedBackSpace() Then Button2Click() Sleep(50) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func ListViewPopulate($path) _GUICtrlListView_BeginUpdate($ListView1) GUICtrlSetData($progressbar1, 0) _GUIImageList_Destroy($lImage) $lImage = _GUIImageList_Create($iCX, $iCY, 5, 3) _GUICtrlListView_SetImageList($ListView1, $lImage, 0) _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1)) _FileFolderArray($path) ;create array of files and folders $Percentage = 100 / ((UBound($FileList) - 1) + (UBound($FolderList) - 1)) ; used for calculating percentage completion of populating listview Local $FolderImageListIconIndex = 0 For $Shaheen = 2 To 1 Step -1 If $Shaheen == 2 Then If UBound($FolderList) > 0 Then ; loop through folder array first For $i = 1 To UBound($FolderList) - 1 $fullpath = $path & "" & $FolderList[$i] _GUICtrlListView_AddItem($ListView1, $FolderList[$i], $FolderImageListIconIndex) $FolderImageListIconIndex += 1 GUICtrlSetData($Progress1, Int($Percentage * $i)) Next EndIf Else Local $FileImageListIconIndex = $FolderImageListIconIndex If UBound($FileList) > 0 Then ; loop through file array For $i = 1 To UBound($FileList) - 1 $ext = StringMid($FileList[$i], StringInStr($FileList[$i], '.', 0, -1)) $fullpath = $path & "" & $FileList[$i] _GUICtrlListView_AddItem($ListView1, $FileList[$i], $FileImageListIconIndex) $FileImageListIconIndex += 1 GUICtrlSetData($Progress1, Int($Percentage * ($i + $FolderList[0]))) Next EndIf EndIf Next _GUICtrlListView_EndUpdate($ListView1) ExtractIconoverlay() $FolderIconIndex = 1 $FileIconIndex = 1 $folderIconsDone = False EndFunc ;==>ListViewPopulate Func _FileFolderArray($sPath) ;Create Array of files and folders for future use Local $hSearch, $sFile, $asFileList[1], $asFolderList[1] $FileList = 0 $FolderList = 0 If Not FileExists($sPath) Then Return $hSearch = FileFindFirstFile($sPath & "" & "*.*") If $hSearch = -1 Then Return While 1 $sFile = FileFindNextFile($hSearch) If @error Then SetError(0) ExitLoop EndIf If StringInStr(FileGetAttrib($sPath & "" & $sFile), "D") == 0 Then $asFileList[0] += 1 If UBound($asFileList) <= $asFileList[0] Then ReDim $asFileList[UBound($asFileList) * 2] $asFileList[$asFileList[0]] = $sFile ContinueLoop Else $asFolderList[0] += 1 If UBound($asFolderList) <= $asFolderList[0] Then ReDim $asFolderList[UBound($asFolderList) * 2] $asFolderList[$asFolderList[0]] = $sFile EndIf WEnd FileClose($hSearch) ReDim $asFileList[$asFileList[0] + 1] ReDim $asFolderList[$asFolderList[0] + 1] $FileList = $asFileList $FolderList = $asFolderList $asFileList = 0 $asFolderList = 0 EndFunc ;==>_FileFolderArray Func _IconLoad() If $folderIconsDone == False Then If UBound($FolderList) > 0 Then If $FolderIconIndex > $FolderList[0] Then $folderIconsDone = True Return EndIf Local $location = $Inputtext & "" & $FolderList[$FolderIconIndex] $attributes = FileGetAttrib($location) Select Case $iCX == 32 Or $iCX == 16 IconsLoad_16_32($location) Case $iCX == 48 Or $iCX == 64 Or $iCX == 128 Or $iCX == 256 IconsLoadImageList($location, "Folder", "") EndSelect _GUICtrlListView_RedrawItems($ListView1, $FolderIconIndex - 1, $FolderIconIndex - 1) $FolderIconIndex += 1 Else $folderIconsDone = True EndIf EndIf If UBound($FileList) > 0 Then If $folderIconsDone == True Then If $FileIconIndex > $FileList[0] Then Return EndIf Local $location = $Inputtext & "" & $FileList[$FileIconIndex] $attributes = FileGetAttrib($location) Local $type = "File" $szExt = StringMid($FileList[$FileIconIndex], StringInStr($FileList[$FileIconIndex], '.', 0, -1)) If $szExt == ".lnk" Then $shcut = FileGetShortcut($location) If IsArray($shcut) Then If $shcut[0] <> "" Then $location = $shcut[0] EndIf If StringInStr(FileGetAttrib($location), "D") == 0 Then $szExt = StringMid($location, StringInStr($location, '.', 0, -1)) Else $type = "Folder" EndIf $AddIconOverlay = True If IsArray($shcut) Then If $shcut[0] == "" Then $AddIconOverlay = False EndIf Else $AddIconOverlay = False EndIf Select Case $iCX == 32 Or $iCX == 16 IconsLoad_16_32($location) Case $iCX == 48 Or $iCX == 64 Or $iCX == 128 Or $iCX == 256 IconsLoadImageList($location, $type, $szExt) EndSelect _GUICtrlListView_RedrawItems($ListView1, $FolderIconIndex + $FileIconIndex - 2, $FolderIconIndex + $FileIconIndex - 2) If $FileIconIndex == $FileList[0] Then $AddIconOverlay = False _ReduceMemory() EndIf $FileIconIndex += 1 EndIf EndIf EndFunc ;==>_IconLoad Func IconsLoadImageList($location, $type, $ext = "") If $type == "Folder" Then If $IShellItemImageFactoryIsInterfaceAvailable == False Then Local $tSHFILEINFO = DllStructCreate($tagSHFILEINFO) _WinAPI_ShellGetFileInfo($location, 0x00001000, 0, $tSHFILEINFO) $hIcon = _WinAPI_ShellExtractIcon(DllStructGetData($tSHFILEINFO, 4), DllStructGetData($tSHFILEINFO, 2), $iCX, $iCX) If $AddIconOverlay == True And $ext == ".lnk" Then $hIcon = AddIconOverlay($hIcon) If StringInStr($attributes, "H") Then $hIcon = _WinAPI_Create32BitHICON($hIcon) $hIcon = _WinAPI_AddIconTransparency($hIcon, 50) EndIf $iIndex = _GUIImageList_ReplaceIcon($lImage, -1, $hIcon) If $iIndex == -1 Then $hIcon = _WinAPI_ShellExtractIcon($ResourceFile, 3, $iCX, $iCX) If $AddIconOverlay == True And $ext == ".lnk" Then $hIcon = AddIconOverlay($hIcon) If StringInStr($attributes, "H") Then $hIcon = _WinAPI_Create32BitHICON($hIcon) $hIcon = _WinAPI_AddIconTransparency($hIcon, 50) EndIf _GUIImageList_ReplaceIcon($lImage, -1, $hIcon) EndIf _WinAPI_DestroyIcon($hIcon) Else If _IShellFolder_Extract_hBMP($location) == 0 Then ZIconPreviewXP($ext, $location) EndIf Else If $IShellItemImageFactoryIsInterfaceAvailable == False Then If FileIconPreviewXP($location) == 0 Then ZIconPreviewXP($ext, $location) Else If _IShellFolder_Extract_hBMP($location) == 0 Then ZIconPreviewXP($ext, $location) EndIf EndIf EndFunc ;==>IconsLoadImageList Func IconsLoad_16_32($location) Local $large = 0 If $iCX == 16 Then $large = 1 $hIcon = _WinAPI_ShellExtractAssociatedIcon($location, $large) If $AddIconOverlay == True Then $hIcon = AddIconOverlay($hIcon) If StringInStr($attributes, "H") Then $hIcon = _WinAPI_Create32BitHICON($hIcon) $hIcon = _WinAPI_AddIconTransparency($hIcon, 50) EndIf _GUIImageList_ReplaceIcon($lImage, -1, $hIcon) _WinAPI_DestroyIcon($hIcon) EndFunc ;==>IconsLoad_16_32 Func GlobalIcon($location, $ishell) $hIcon = _WinAPI_ShellExtractAssociatedIcon($location, 0) If $AddIconOverlay == True Then $hIcon = AddIconOverlay($hIcon) $Hbitmap = _CreateBitmapFromIconEx(0xF8F8F8, 32, 32, $hIcon) $hBmp = _IShellFolder_GetImage($Hbitmap, $ishell, $ishell) If Not StringInStr($attributes, "H") Then _GUIImageList_Add($lImage, $hBmp) Else Convert_Bitmpap_ToIcon_And_Add_Transparency($hBmp) EndIf _WinAPI_DestroyIcon($hIcon) _WinAPI_DeleteObject($Hbitmap) _WinAPI_DeleteObject($hBmp) EndFunc ;==>GlobalIcon Func ExtractIconOverlay() _WinAPI_DestroyIcon($hOverlay) $hOverlay = _WinAPI_ShellExtractIcon($ResourceFile, $overlayindex, $iCX, $iCX) EndFunc ;==>ExtractIconOverlay Func AddIconOverlay($hIcon) $hResult = _WinAPI_AddIconOverlay($hIcon, $hOverlay) Return $hResult EndFunc ;==>AddIconOverlay Func GetIconGroupInfo($iconfile, $iconindex, $iCX) $hInstance = _WinAPI_LoadLibraryEx($iconfile, $LOAD_LIBRARY_AS_DATAFILE) If Not $hInstance Then Return 0 If $iconindex < 0 Then $iconindex = -1 * $iconindex $hResource = _WinAPI_FindResource($hInstance, $RT_GROUP_ICON, $iconindex) If $hResource == 0 Then _WinAPI_FreeLibrary($hInstance) Return 0 EndIf $hData = _WinAPI_LoadResource($hInstance, $hResource) $pData = _WinAPI_LockResource($hData) $iIcon = _WinAPI_LookupIconIdFromDirectoryEx($pData, 1, $iCX, $iCX) $hResource = _WinAPI_FindResource($hInstance, $RT_ICON, $iIcon) $iSize = _WinAPI_SizeOfResource($hInstance, $hResource) $hData = _WinAPI_LoadResource($hInstance, $hResource) $pData = _WinAPI_LockResource($hData) $hIcon = _WinAPI_CreateIconFromResourceEx($pData, $iSize) ; Create icon from resource $tSize = _WinAPI_GetIconDimension($hIcon) If $AddIconOverlay == True Then $hIcon = AddIconOverlay($hIcon) $Hbitmap = _CreateBitmapFromIconEx(0xF8F8F8, DllStructGetData($tSize, 'X'), DllStructGetData($tSize, 'Y'), $hIcon) $hBmp = _IShellFolder_GetImage($Hbitmap, $iCX, $iCX) If Not StringInStr($attributes, "H") Then _GUIImageList_Add($lImage, $hBmp) Else Convert_Bitmpap_ToIcon_And_Add_Transparency($hBmp) EndIf _WinAPI_DestroyIcon($hIcon) _WinAPI_DeleteObject($Hbitmap) _WinAPI_DeleteObject($hBmp) _WinAPI_FreeLibrary($hInstance) Return 1 EndFunc ;==>GetIconGroupInfo Func DrawImage($location) $hBmp = _GDIPlus_BitmapCreateFromGraphics($iCX, $iCX, $hGraphics1) $hGraphics2 = _GDIPlus_ImageGetGraphicsContext($hBmp) $hImage = _GDIPlus_ImageLoadFromFile($location) $Width = _GDIPlus_ImageGetWidth($hImage) $Height = _GDIPlus_ImageGetHeight($hImage) $iRatio = $Width / $Height $h = $iCX / $iRatio If $h > $iCX Then $h = $iCX $y = 0 $w = $iCX * $iRatio $x = ($iCX - $w) / 2 Else $x = 0 $w = $iCX $y = ($iCX - $h) / 2 EndIf If $Width < $iCX And $Height < $iCX Then Local $aGS = _IShellFolder_GetScale($Width, $Height, $iCX) _GDIPlus_GraphicsDrawImageRect($hGraphics2, $hImage, $aGS[0], $aGS[1], $aGS[2], $aGS[3]) Else _GDIPlus_GraphicsDrawImageRect($hGraphics2, $hImage, $x, $y, $w, $h) EndIf $hHBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp) If StringInStr($attributes, "H") Then Convert_Bitmpap_ToIcon_And_Add_Transparency($hHBMP) Else _GUIImageList_Add($lImage, $hHBMP) EndIf _GDIPlus_BitmapDispose($hBmp) _GDIPlus_GraphicsDispose($hGraphics2) _GDIPlus_ImageDispose($hImage) _WinAPI_DeleteObject($hHBMP) EndFunc ;==>DrawImage Func _CreateBitmapFromIconEx($iBackground, $iWidth, $iHeight, $hIcon) ; by Yashied Local $hDC, $hBackDC, $hBackSv, $Hbitmap $hDC = _WinAPI_GetDC(0) $hBackDC = _WinAPI_CreateCompatibleDC($hDC) $Hbitmap = _WinAPI_CreateSolidBitmap(0, 0xFFFFFFFF, $iWidth, $iHeight) $hBackSv = _WinAPI_SelectObject($hBackDC, $Hbitmap) If Not @error Then _WinAPI_DrawIconEx($hBackDC, 0, 0, $hIcon, $iWidth, $iWidth, 0, 0, 3) EndIf _WinAPI_SelectObject($hBackDC, $hBackSv) _WinAPI_ReleaseDC(0, $hDC) _WinAPI_DeleteDC($hBackDC) Return $Hbitmap EndFunc ;==>_CreateBitmapFromIconEx Func _IShellFolder_Extract_hBMP($sFileName) Local $pImgFact, $h_IShellFolder_Bmp If 0 = _IShellFolder_SHCreateItemFromParsingName($sFileName, 0, DllStructGetPtr($tIIDImgFact), $pImgFact) And $pImgFact Then ; use IShellItemImageFactory interface Local $r[4] $o_AUObj_IImgFact = _AutoItObject_WrapperCreate($pImgFact, $dtagIShellItemImageFactory) If Not StringInStr($attributes, "D") Then $r = $o_AUObj_IImgFact.GetImage(_IShellFolder_MakeUINT64($iCX, $iCX), 8, 0) ; <==== _IShellFolder_MakeUINT64 added If Not $r[3] Then ; no thumbnail available OR target is folder $r = $o_AUObj_IImgFact.GetImage(_IShellFolder_MakeUINT64($iCX, $iCX), 0, 0) ; <==== _IShellFolder_MakeUINT64 added $h_IShellFolder_Bmp = $r[3] Else $h_IShellFolder_Bmp = _IShellFolder_GetImage($r[3], $iCX, $iCX) EndIf $o_AUObj_IImgFact = 0 Else Return 0 EndIf If StringInStr($attributes, "H") Then Convert_Bitmpap_ToIcon_And_Add_Transparency($h_IShellFolder_Bmp) Else _GUIImageList_Add($lImage, $h_IShellFolder_Bmp) EndIf _WinAPI_DeleteObject($h_IShellFolder_Bmp) Return 1 EndFunc ;==>_IShellFolder_Extract_hBMP Func Convert_Bitmpap_ToIcon_And_Add_Transparency($hBmp) $IndirectIcon = _WinAPI_CreateIconIndirect($hBmp, $hBmp) $IndirectIcon = _WinAPI_Create32BitHICON($IndirectIcon) $hIcon2 = _WinAPI_AddIconTransparency($IndirectIcon, 50) _GUIImageList_ReplaceIcon($lImage, -1, $hIcon2) _WinAPI_DestroyIcon($IndirectIcon) _WinAPI_DestroyIcon($hIcon2) EndFunc ;==>Convert_Bitmpap_ToIcon_And_Add_Transparency Func _IShellFolder_GetImage($hBmp_Source, $i_TargetWidth = 32, $i_TargetHeight = 32) ; by Yashied Local $tBMP = DllStructCreate($tagBITMAP) _WinAPI_GetObject($hBmp_Source, DllStructGetSize($tBMP), DllStructGetPtr($tBMP)) Local $iW = DllStructGetData($tBMP, "bmWidth"), $iH = Abs(DllStructGetData($tBMP, "bmHeight")) Local $aGS = _IShellFolder_GetScale($iW, $iH, $i_TargetWidth) $hDC = _WinAPI_GetDC(0) $hDestDC = _WinAPI_CreateCompatibleDC($hDC) $hBmp = _WinAPI_CreateCompatibleBitmapEx($hDC, $i_TargetWidth, $i_TargetHeight, 0xFFFFFFFF) $hDestSv = _WinAPI_SelectObject($hDestDC, $hBmp) $hSrcDC = _WinAPI_CreateCompatibleDC($hDC) $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hBmp_Source) If _WinAPI_IsAlphaBitmap($hBmp_Source) Then $result = _WinAPI_AlphaBlend($hDestDC, $aGS[0], $aGS[1], $aGS[2], $aGS[3], $hSrcDC, 0, 0, $iW, $iH, 255, 1) Else $result = _WinAPI_AlphaBlend($hDestDC, $aGS[0], $aGS[1], $aGS[2], $aGS[3], $hSrcDC, 0, 0, $iW, $iH, 255, 0) EndIf If $IShellItemImageFactoryIsInterfaceAvailable == False Then If $iCX > 64 Then If $iW < $iCX Then $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP($hBmp) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage2) _GDIPlus_GraphicsDrawRect($hGraphic, 2, 2, $iCX - 4, $iCX - 4, $hPen) $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage2) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_BitmapDispose($hImage2) EndIf EndIf EndIf _WinAPI_ReleaseDC(0, $hDC) _WinAPI_SelectObject($hDestDC, $hDestSv) _WinAPI_SelectObject($hSrcDC, $hSrcSv) _WinAPI_DeleteDC($hDestDC) _WinAPI_DeleteDC($hSrcDC) Return $hBmp EndFunc ;==>_IShellFolder_GetImage Func _IShellFolder_GetScale($iW, $iH, $i_TargetWidth) Local $aRet[4] If $iW <= $i_TargetWidth And $iH <= $i_TargetWidth Then $aRet[2] = $iW $aRet[3] = $iH $aRet[0] = ($i_TargetWidth - $aRet[2]) / 2 $aRet[1] = ($i_TargetWidth - $aRet[3]) / 2 ElseIf $iW > $iH Then $aRet[2] = $i_TargetWidth $aRet[3] = $iH / ($iW / $i_TargetWidth) $aRet[0] = 0 $aRet[1] = ($i_TargetWidth - $aRet[3]) / 2 ElseIf $iW < $iH Then $aRet[2] = $iW / ($iH / $i_TargetWidth) $aRet[3] = $i_TargetWidth $aRet[0] = ($i_TargetWidth - $aRet[2]) / 2 $aRet[1] = 0 ElseIf $iW = $iH Then $aRet[2] = $i_TargetWidth $aRet[3] = $i_TargetWidth $aRet[0] = 0 $aRet[1] = 0 EndIf Return $aRet EndFunc ;==>_IShellFolder_GetScale Func DrawIcon($sFile) $iSize = FileGetSize($sFile) $tData = DllStructCreate('byte[' & $iSize & ']') $pData = DllStructGetPtr($tData) $hFile = _WinAPI_CreateFile($sFile, 2, 2, 6) _WinAPI_ReadFile($hFile, $pData, $iSize, $iSize) _WinAPI_CloseHandle($hFile) $tHdr = DllStructCreate($tagICOHEADER, $pData) $Count = DllStructGetData($tHdr, 'Count') Dim $arrayico[$Count + 1] For $i = 1 To $Count ; this part by yashied $tEntry = DllStructCreate($tagICOENTRY, $pData + 6 + 16 * ($i - 1)) $pIcon = $pData + DllStructGetData($tEntry, 'Offset') $Offset = DllStructGetData($tEntry, 'Offset') If DllStructGetData(DllStructCreate('byte[8]', $pIcon), 1) = Binary('0x89504E470D0A1A0A') Then ; PNG => Retrieve IHDR chunk data (always first chunk, offset = 8) $tHdr = DllStructCreate($tagIHDR, $pIcon + 16) $Width = _WinAPI_SwapDWord(DllStructGetData($tHdr, 'Width')) $Height = _WinAPI_SwapDWord(DllStructGetData($tHdr, 'Height')) $Png = ' (PNG)' Else ; ICO => Retrieve BITMAPINFOHEADER structure $tHdr = DllStructCreate($tagBITMAPINFOHEADER, $pIcon) $Width = DllStructGetData($tHdr, 'biWidth') $Height = DllStructGetData($tHdr, 'biHeight') / 2 $Png = '' EndIf If $Width == $iCX And $Height == $iCX Then $hIcon = _WinAPI_ShellExtractIcon($sFile, 0, $Width, $Width) If $AddIconOverlay == True Then $hIcon = AddIconOverlay($hIcon) If StringInStr($attributes, "H") Then $hIcon = _WinAPI_Create32BitHICON($hIcon) $hIcon = _WinAPI_AddIconTransparency($hIcon, 50) EndIf _GUIImageList_ReplaceIcon($lImage, -1, $hIcon) _WinAPI_DestroyIcon($hIcon) Return EndIf $arrayico[$i] = $Width Next _ArraySort($arrayico) Local $aNewArray = _ArrayUnique($arrayico) For $z = (UBound($aNewArray) - 1) To 1 Step -1 If $aNewArray[$z] >= $iCX Then $iIndex = _WinAPI_LookupIconIdFromDirectoryEx($pData, 1, $iCX, $iCX) $hIcon = _WinAPI_ShellExtractIcon($sFile, -1 * $iIndex, $iCX, $iCX) If $AddIconOverlay == True Then $hIcon = AddIconOverlay($hIcon) If StringInStr($attributes, "H") Then $hIcon = _WinAPI_Create32BitHICON($hIcon) $hIcon = _WinAPI_AddIconTransparency($hIcon, 50) EndIf _GUIImageList_ReplaceIcon($lImage, -1, $hIcon) _WinAPI_DestroyIcon($hIcon) Return EndIf Next For $y = (UBound($aNewArray) - 1) To 1 Step -1 If $aNewArray[$y] <= $iCX Then $hIcon = _WinAPI_ShellExtractIcon($sFile, 0, $aNewArray[$y], $aNewArray[$y]) If $AddIconOverlay == True Then $hIcon = AddIconOverlay($hIcon) $Hbitmap = _CreateBitmapFromIconEx(0xF8F8F8, $aNewArray[$y], $aNewArray[$y], $hIcon) $hBmp = _IShellFolder_GetImage($Hbitmap, $iCX, $iCX) If Not StringInStr($attributes, "H") Then _GUIImageList_Add($lImage, $hBmp) Else Convert_Bitmpap_ToIcon_And_Add_Transparency($hBmp) EndIf _WinAPI_DestroyIcon($hIcon) _WinAPI_DeleteObject($Hbitmap) _WinAPI_DeleteObject($hBmp) Return EndIf Next EndFunc ;==>DrawIcon Func FileIconPreviewXP($location) $pidl = _IShellFolder_ILCreateFromPath($location) Dim $pIShellFolder, $pRelative $tRIID = _AutoItObject_CLSIDFromString($sIID_IShellFolder) $tRIIDExtract = _AutoItObject_CLSIDFromString($sIID_IExtractImage) _SHBindToParent($pidl, DllStructGetPtr($tRIID), $pIShellFolder, $pRelative) $IShellFolder = _AutoItObject_WrapperCreate($pIShellFolder, $dtagIShellFolder) $tSTRRET = DllStructCreate("uint uType;ptr data;") If IsObj($IShellFolder) Then $r = $IShellFolder.GetDisplayNameOf(Number($pRelative), 0, Number(DllStructGetPtr($tSTRRET))) Else Return 0 EndIf Dim $name _IShellFolder_StrRetToBuf(DllStructGetPtr($tSTRRET), 0, $name, 512) $tSTRRET = 0 $tArray = DllStructCreate("ptr") DllStructSetData($tArray, 1, $pRelative) $r = $IShellFolder.GetUIObjectOf(0, 1, Number(DllStructGetPtr($tArray)), Number(DllStructGetPtr($tRIIDExtract)), 0, 0) $IExtractImage = _AutoItObject_WrapperCreate($r[6], $dtagIExtractImage) If Not IsObj($IExtractImage) Then Return 0 Else $tSize = DllStructCreate("long;long") DllStructSetData($tSize, 1, $iCX) DllStructSetData($tSize, 2, $iCX) $r = $IExtractImage.GetLocation("", 1024, 0, Number(DllStructGetPtr($tSize)), 32, 0x0020 + 0x0200) ;IEIFLAG_SCREEN + IEIFLAG_QUALITY $r = $IExtractImage.Extract(0) $IShellFolder = 0 _IShellFolder_CoTaskMemFree($pidl) $IExtractImage = 0 $hBmp = _IShellFolder_GetImage($r[1], $iCX, $iCX) If Not StringInStr($attributes, "H") Then _GUIImageList_Add($lImage, $r[1]) Else Convert_Bitmpap_ToIcon_And_Add_Transparency($hBmp) EndIf EndIf _WinAPI_DeleteObject($r[1]) _WinAPI_DeleteObject($hBmp) Return 1 EndFunc ;==>FileIconPreviewXP Func ZIconPreviewXP($ext, $location) If $ext <> "" Then Select Case $ext = ".exe" $Data = _WinAPI_EnumResourceNames($location, $RT_GROUP_ICON) If UBound($Data) > 1 Then If GetIconGroupInfo($location, $Data[1], $iCX) == 0 Then GetIconGroupInfo($ResourceFile, $noiconexeindex + 1, $iCX) Else GetIconGroupInfo($ResourceFile, $noiconexeindex + 1, $iCX) EndIf Case $ext = ".ani" Or $ext = ".cur" GlobalIcon($location, $iCX) Case $ext = ".ico" DrawIcon($location) Case Else If $ext = ".bmp" Or $ext = ".jpg" Or $ext = ".jpeg" Or $ext = ".png" Or $ext = ".gif" Or $ext = ".bmp" Or $ext = ".tif" Or $ext = ".tiff" Or $ext = ".exif" Then If $iCX == 64 Or $iCX == 128 Or $iCX == 256 Then DrawImage($location) Return EndIf EndIf $iconlocation = _WinAPI_AssocQueryString($ext, $ASSOCSTR_DEFAULTICON) $iconlocation = StringSplit($iconlocation, ",") If UBound($iconlocation) > 1 Then $ExpandedPath = _ExpandEnvStrings($iconlocation[1]) If StringRight($ExpandedPath, 1) == '"' And StringLeft($ExpandedPath, 1) == '"' Then $ExpandedPath = StringTrimRight($ExpandedPath, 1) $ExpandedPath = StringTrimLeft($ExpandedPath, 1) $ExpandedPath = FileGetLongName($ExpandedPath) EndIf $extension = StringMid($ExpandedPath, StringInStr($ExpandedPath, '.', 0, -1)) EndIf If UBound($iconlocation) > 2 Then If $extension == ".ico" Then DrawIcon($ExpandedPath) Return EndIf If $extension == ".exe" Or $extension == ".EXE" Or $extension == ".dll" Then $Data = _WinAPI_EnumResourceNames($ExpandedPath, $RT_GROUP_ICON) If $iconlocation[2] >= 0 Then $iconlocation[2] = $Data[$iconlocation[2] + 1] EndIf If GetIconGroupInfo($ExpandedPath, $iconlocation[2], $iCX) == 0 Then GetIconGroupInfo($ResourceFile, $noiconindex + 1, $iCX) EndIf Else ; else ther is no index then maybe its a .ico file If $extension == ".ico" Then If UBound($iconlocation) > 1 Then DrawIcon($ExpandedPath) Else GlobalIcon($location, $iCX) EndIf Else GlobalIcon($location, $iCX) EndIf EndIf EndSelect Else GlobalIcon($location, $iCX) EndIf EndFunc ;==>ZIconPreviewXP Func _IShellFolder_MakeUINT64($long1, $long2) Local $d = DllStructCreate("align 4;dword[2]") DllStructSetData($d, 1, $long1, 1) DllStructSetData($d, 1, $long2, 2) Return DllStructGetData(DllStructCreate("uint64", DllStructGetPtr($d)), 1) EndFunc ;==>_IShellFolder_MakeUINT64 Func _IShellFolder_CoTaskMemFree($pMem) Local $aRes = DllCall("Ole32.dll", "none", "CoTaskMemFree", "ptr", $pMem) If @error Then SetError(1) EndFunc ;==>_IShellFolder_CoTaskMemFree Func _IShellFolder_ILCreateFromPath($sPath) Local $aRes = DllCall("shell32.dll", "ptr", "ILCreateFromPathW", "wstr", $sPath) If @error Then Return SetError(1, 0, 0) Return $aRes[0] EndFunc ;==>_IShellFolder_ILCreateFromPath Func _IShellFolder_SHCreateItemFromParsingName($szPath, $pbc, $riid, ByRef $pv) Local $aRes = DllCall("shell32.dll", "long", "SHCreateItemFromParsingName", "wstr", $szPath, "ptr", $pbc, "ptr", $riid, "ptr*", 0) If @error Then Return SetError(1, 0, 0) $pv = $aRes[4] Return $aRes[0] EndFunc ;==>_IShellFolder_SHCreateItemFromParsingName Func _IShellFolder_SHBindToObject($psf, $pidl, $pbc, $riid, ByRef $pv) Local $aRes = DllCall("Shell32.dll", "long", "SHBindToObject", "ptr", $psf, "ptr", $pidl, "ptr", $pbc, "ptr", $riid, "ptr*", 0) If @error Then Return SetError(1, 0, 0) $pv = $aRes[5] Return $aRes[0] EndFunc ;==>_IShellFolder_SHBindToObject Func _SHBindToParent($pidl, $riid, ByRef $pv, ByRef $pidlLast) Local $aRes = DllCall("Shell32.dll", "long", "SHBindToParent", "ptr", $pidl, "ptr", $riid, "ptr*", 0, "ptr*", 0) If @error Then Return SetError(1, 0, 0) $pv = $aRes[3] $pidlLast = $aRes[4] Return $aRes[0] EndFunc ;==>_SHBindToParent Func _IShellFolder_StrRetToBuf($pSTRRET, $pidl, ByRef $sName, $iLength = 512) Local $aRes = DllCall("shlwapi.dll", "long", "StrRetToBufW", "ptr", $pSTRRET, "ptr", $pidl, "wstr", $sName, "uint", $iLength) If @error Then Return SetError(1, 0, 0) $sName = $aRes[3] Return $aRes[0] EndFunc ;==>_IShellFolder_StrRetToBuf Func _ExpandEnvStrings($sInput) ; thanks to blindwig for this func Dim $aPart = StringSplit($sInput, '%') If @error Then SetError(1) Return $sInput EndIf Dim $sOut = $aPart[1], $i = 2, $env = '' ;loop through the parts While $i <= $aPart[0] $env = EnvGet($aPart[$i]) If $env <> '' Then ;this part is an expandable environment variable $sOut = $sOut & $env $i = $i + 1 If $i <= $aPart[0] Then $sOut = $sOut & $aPart[$i] ElseIf $aPart[$i] = '' Then ;a double-percent is used to force a single percent $sOut = $sOut & '%' $i = $i + 1 If $i <= $aPart[0] Then $sOut = $sOut & $aPart[$i] Else ;this part is to be returned literally $sOut = $sOut & '%' & $aPart[$i] EndIf $i = $i + 1 WEnd Return $sOut EndFunc ;==>_ExpandEnvStrings Func _ReduceMemory($i_PID = -1) ;Reduces Memory Usage -- Special thanks to w0uter and jftuga If $i_PID <> -1 Then Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) Else Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) EndIf Return $ai_Return[0] EndFunc ;==>_ReduceMemory Func ToolTipEx() $htItem = _GUICtrlListView_HitTest(GUICtrlGetHandle($ListView1)) If $htItem[0] <> -1 And WinActive($Form1_1) Then Local $itemtext = _GUICtrlListView_GetItemText($ListView1, $htItem[0]) Local $association = "" Local $type = "" If $itemtext <> $oldtip Then $attrib = FileGetAttrib($Inputtext & "" & $itemtext) Local $aItem_Rect = _GUICtrlListView_GetItemRect($ListView1, $htItem[0], 2) Local $aLV_Pos = WinGetPos(GUICtrlGetHandle($ListView1)) If IsDrive($itemtext) Then $type = "Drive" If $type <> "Drive" Then If Not StringInStr($attrib, "D") Then $ext = StringMid($itemtext, StringInStr($itemtext, '.', 0, -1)) If $ext == "" Then $type = StringUpper(StringRight($itemtext, StringLen($itemtext) - StringInStr($itemtext, ".", 0, -1))) & " File" Else $type = _WinAPI_AssocQueryString($ext, $ASSOCSTR_FRIENDLYDOCNAME) Select Case $ext = ".lnk" $scut = FileGetShortcut($Inputtext & "" & $itemtext) $association = $scut[0] Case $ext = ".exe" Or $ext = ".com" Or $ext = ".pif" $association = "Self Executable" Case Else $association = _WinAPI_AssocQueryString($ext, $ASSOCSTR_FRIENDLYAPPNAME) EndSelect EndIf $size = SizeEx(FileGetSize($Inputtext & "" & $itemtext)) Else $type = "Folder" $association = "Windows Explorer" $date = FolderDate($Inputtext & "" & $itemtext) EndIf EndIf If $association == "" Then $association = "Unknown Application" If $type <> "Folder" And $type <> "Drive" Then $tooltext = ($itemtext & @LF & $type & @LF & $size & @LF & $association & @LF & AttribExpand($attrib)) ElseIf $type == "Folder" Then $tooltext = ($itemtext & @LF & $type & @LF & $date & $association & @LF & AttribExpand($attrib)) ElseIf $type == "Drive" Then $slabel = "Label : " & DriveGetLabel($itemtext & "") If DriveGetLabel($itemtext & "") == "" Then $slabel = "Label : (No Label)" $status = "Status : " & DriveStatus($itemtext & "") $dtype = "Type : " & DriveGetType($itemtext & "") $fsystem = "File System : " & DriveGetFileSystem($itemtext & "") If DriveGetFileSystem($itemtext & "") = "UDF" Then $dtype = "Type : DVDROM" If @error == 1 Then $fsystem = "File System : Unknown" $tspace = "Total Space : " & SizeEx(DriveSpaceTotal($itemtext & "") * 1024 * 1024) $fspace = "Space Free : " & SizeEx(DriveSpaceFree($itemtext & "") * 1024 * 1024) $uspace = "Used Space : " & SizeEx((DriveSpaceTotal($itemtext & "") - DriveSpaceFree($itemtext & "")) * 1024 * 1024) $tooltext = $slabel & @LF & $status & @LF & $dtype & @LF & $fsystem & @LF & $tspace & @LF & $fspace & @LF & $uspace EndIf ToolTip($tooltext, $aLV_Pos[0] + $aItem_Rect[0], $aLV_Pos[1] + $aItem_Rect[1] + 5, "", "", 4) $oldtip = $itemtext EndIf Else ToolTip("") $oldtip = "" EndIf EndFunc ;==>ToolTipEx Func IsDrive($letter) Local $aArray = DriveGetDrive("ALL") For $i = 1 To $aArray[0] If $aArray[$i] = $letter Then Return 1 Next Return 0 EndFunc ;==>IsDrive Func FolderDate($folderpath) Local $alltime For $z = 0 To 2 $date = FileGetTime($folderpath, $z) Select Case $z == 0 $dw = "Modified : " Case $z == 1 $dw = "Created : " Case $z == 2 $dw = "Accessed : " EndSelect Local $datetime = "", $AP = "AM" For $i = 0 To 2 $datetime &= $date[$i] If $i < 2 Then $datetime &= "-" If $i = 2 Then $datetime &= " " Next If $date[3] > 12 Then $date[3] = $date[3] - 12 $AP = "PM" EndIf If $date[3] = 12 Then $AP = "PM" If $date[3] = 0 Then $date[3] = 12 $time = $date[3] & ":" & $date[4] & ":" & $date[5] & " " & $AP $alltime &= $dw & $datetime & " " & $time & @LF Next Return $alltime EndFunc ;==>FolderDate Func SizeEx($size) Select Case $size = 0 $size = "0 Bytes" Case $size >= 1073741824 $size = Round($size / 1073741824, 2) & " " & "GB" Case $size >= 1048576 $size = Round($size / 1048576, 2) & " " & "MB" Case $size >= 1024 $size = Round($size / 1024, 2) & " " & "KB" Case $size < 1024 $size = Int($size) & " " & "Bytes" EndSelect Return $size EndFunc ;==>SizeEx Func AttribExpand($sAttribute) Local $aInput = StringSplit("R,A,S,H,N,D,O,C,T", ",") Local $aOutput = StringSplit("Read-only /,Archive /,System /,Hidden /" & _ ",Normal /,Directory /,Offline /,Compressed /,Temporary /", ",") For $i = 1 To $aInput[0] $sAttribute = StringReplace($sAttribute, $aInput[$i], $aOutput[$i], 0, 1) Next $sAttribute = StringTrimRight($sAttribute, 2) Return $sAttribute EndFunc ;==>AttribExpand Link to pastebin formatted code: http://pastebin.com/bi1Abjmn
  18. great excellent work.
  19. hi. how to retrieve dimensions of all icons which are present in a single ".ico" file. this might be useful . http://www.codeproject.com/Articles/6171/Access-multiple-icons-in-a-single-icon-file but i cant understand its complexity.
  20. if i open a 32x32 icon with a icon editor i see the same icon of different pixels. how shall i retrieve the dimensions of them all.. because with $hImage = _GDIPlus_ImageLoadFromFile("example.ico") _GDIPlus_ImageGetWidth($hImage) and _GDIPlus_ImageGetHeight($hImage) we get only one size of icon not dimensions of other icons present in the icon file
  21. once again thanks. brilliant
  22. its not working for .ico files
×
×
  • Create New...