Jump to content

See Entire Map


xzaz
 Share

Recommended Posts

See GUICtrlCreateListview (check the styles) and the GUIListView UDFs

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

So i should use _GUICtrlListAddDir() But you can use that function only with GUICtrlCreateList. And with that function you cant use $LVS_ICON

I got this so far

#include <Color.au3>
#include <GUIConstants.au3>
#include <Functions/Functions.au3>
#include <GuiList.au3>
$a_attr = StringSplit("A,D,H,RO,RW,S,E,Drives,NB", ",")
$desktopw = @DesktopWidth
$desktoph = @DesktopHeight 
$path = "c:/"


;Start GUI
GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0 , $WS_POPUP)
$dir = GUICtrlCreateList ("",10,10,500,500,)

GUISetBkColor(10215351)
GUISetState (@SW_SHOW)   

;chance_res(800,600,32,60)
$msg = GUIGetMsg()
_GUICtrlListAddDir ( $dir,$a_attr,"*.*" )
GUICtrlSetData($dir, $Path)
While 1
    Switch $msg
        Case $GUI_EVENT_CLOSE
            By()
    EndSwitch       
Wend
Link to comment
Share on other sites

So i should use _GUICtrlListAddDir() But you can use that function only with GUICtrlCreateList. And with that function you cant use $LVS_ICON

I got this so far

#include <Color.au3>
#include <GUIConstants.au3>
#include <Functions/Functions.au3>
#include <GuiList.au3>
$a_attr = StringSplit("A,D,H,RO,RW,S,E,Drives,NB", ",")
$desktopw = @DesktopWidth
$desktoph = @DesktopHeight 
$path = "c:/"
;Start GUI
GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0 , $WS_POPUP)
$dir = GUICtrlCreateList ("",10,10,500,500,)

GUISetBkColor(10215351)
GUISetState (@SW_SHOW)   

;chance_res(800,600,32,60)
$msg = GUIGetMsg()
_GUICtrlListAddDir ( $dir,$a_attr,"*.*" )
GUICtrlSetData($dir, $Path)
While 1
    Switch $msg
        Case $GUI_EVENT_CLOSE
            By()
    EndSwitch       
Wend
Read my reply again. It's ListView ...... NOT List. There is a major difference.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

You're getting closer. _FileListToArrayNew should help, it will get you the file listing you need. Now you need to use the results from that and add everything with _GUICtrlListView_AddItem or maybe even _GUICtrlListView_AddArray. I would write up some example code, but as near as I can imagine it won't be small, and I'm just getting ready for work, so unfortunately don't have time. If no one else has posted anything I'll see if I can work something up later.

*bookmarks thread*

Link to comment
Share on other sites

Here's a crude slow example of your code, I know the icons probly don't show the icons you wan't to see and there's no Type column, but mehh ...lol

#include <GUIConstants.au3>
#Include <GuiListView.au3>
#include <File.au3>
#include <String.au3>

Global $path = @ProgramFilesDir & "\AutoIt3"

;Start GUI
$Gui = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0 , $WS_POPUP)
GUISetBkColor(0x9BDFB7, $Gui)
$ListView = GUICtrlCreateListView($path & "|Date Modified|Size",10,10,500,500)
_GUICtrlListViewSetColumnWidth($ListView, 0, 180)  
_SetListViewItems($path)
GUISetState (@SW_SHOW)   

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch      
Wend

Func _SetListViewItems($iPath)
    For $h = 1 To 2
        Local $Sch
        If $h = 1 Then $Sch = _FileListToArray($iPath, "*", 2)
        If $h = 2 Then $Sch = _FileListToArray($iPath, "*", 1)
        For $i = 1 To $Sch[0]
            GUICtrlCreateListViewItem($Sch[$i] & "|" & TimeFormat($iPath & "\" & $Sch[$i]) & "|" & SizeFormat($iPath & "\" & $Sch[$i]), $ListView) 
            If StringInStr(FileGetAttrib($iPath & "\" & $Sch[$i]), "D") Then
                GuiCtrlSetImage(-1, "shell32.dll", -4)
            ElseIf StringRight($Sch[$i], 4) = ".exe" Then
                If GuiCtrlSetImage(-1, $iPath & "\" & $Sch[$i], 0) = 0 Then 
                    GuiCtrlSetImage(-1, "shell32.dll", -3)
                Else    
                    GuiCtrlSetImage(-1, $iPath & "\" & $Sch[$i], 0)
                EndIf   
            Else    
                Local $szIconFile = $iPath & "\" & $Sch[$i], $nIcon = 0
                FileGetIcon($szIconFile, $nIcon, $Sch[$i])
                If $nIcon <> 0 Then $nIcon = - $nIcon
                GuiCtrlSetImage(-1, $szIconFile, $nIcon)
            EndIf
        Next
    Next
EndFunc 

Func SizeFormat($fPath)
    If StringInStr(FileGetAttrib($fPath), "D") Then
        Return " "
    Else    
        Return _StringAddComma(Round(FileGetSize($fPath) / 1024)) & " KB"
    EndIf   
EndFunc

Func TimeFormat($fPath)
    $FGT = FileGetTime($fPath)
    Return $FGT[2] & "/" & $FGT[1] & "/" & $FGT[0] & " " & $FGT[3] & ":" & $FGT[4]
EndFunc

Func FileGetIcon(ByRef $szIconFile, ByRef $nIcon, $szFile)
    Dim $szRegDefault = "", $szDefIcon = ""
    $szExt = StringMid($szFile, StringInStr($szFile, '.', 0, -1))
    If $szExt = '.lnk' Then
        $details = FileGetShortcut($szIconFile)
        $szIconFile = $details[0]
        $szExt = StringMid($details[0], StringInStr($details[0], '.', 0, -1))
    EndIf
    $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 $szRegDefault = RegRead("HKCR\" & $szRegDefault & "\CurVer", "")
    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   ;==>FileGetIcon

Cheers

Edit: adjusted icon finding, still doesn't always find the correct icons for files though.. bah

Not to mention that the folder icon is hard set @ shell32.dll , -4 bad luck if your using another os besides xp ..lol

As well there's no actual drive check or drive icons been incorperated either...

Edited by smashly
Link to comment
Share on other sites

Thats awesome didnt thought the script would be so big. But this is what i got now:

#include <GUIConstants.au3>
#Include <GuiListView.au3>
#include <File.au3>
#include <String.au3>
Run (@comspec & " /c net use m: \\Lisa\Dump\Links", @WindowsDir, @SW_MINIMIZE)
Global $path = "m:"
$font="Verdana"
;Start GUI
$Gui = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0 , $WS_POPUP)
GUISetBkColor(0x9BDFB7, $Gui)
$ListView = GUICtrlCreateListView("Geinstalleerde programma's",10,70,200,500)
$Start = GUICtrlCreateButton("Start",10,600)
GUICtrlSetState(-1,$GUI_DISABLE)
$Browser = GUICtrlCreateButton("Internet",250,70,80,30)
        GUICtrlSetFont (-1,13, 400, 1, $font)
GUICtrlCreateLabel(" " & @UserName,10,10,200,200)
        GUICtrlSetColor(-1,0xffffff)
        GUICtrlSetFont (-1,30, 400, 1, $font)
_GUICtrlListViewSetColumnWidth($ListView, 0, 180) 
_SetListViewItems($path)
GUISetState (@SW_SHOW)   

While 1
    if _GUICtrlListViewGetItemText($ListView) <> "" Then
        GUICtrlSetState($Start,$GUI_ENABLE)
    Else
        GUICtrlSetState($Start,$GUI_DISABLE)
    Endif
        
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $start
            _runselecprogram()
        Case $Browser
            _Browser()
    EndSwitch     
Wend

Func _SetListViewItems($iPath)
    For $h = 1 To 2
        Local $Sch
        If $h = 1 Then $Sch = _FileListToArray($iPath, "*", 2)
        If $h = 2 Then $Sch = _FileListToArray($iPath, "*", 1)
        For $i = 1 To $Sch[0]
            GUICtrlCreateListViewItem($Sch[$i], $ListView)
            If StringInStr(FileGetAttrib($iPath & "\" & $Sch[$i]), "D") Then
                GuiCtrlSetImage(-1, "shell32.dll", -4)
            ElseIf StringRight($Sch[$i], 4) = ".exe" Then
                If GuiCtrlSetImage(-1, $iPath & "\" & $Sch[$i], 0) = 0 Then
                    GuiCtrlSetImage(-1, "shell32.dll", -3)
                Else   
                    GuiCtrlSetImage(-1, $iPath & "\" & $Sch[$i], 0)
                EndIf   
            Else   
                Local $szIconFile = $iPath & "\" & $Sch[$i], $nIcon = 0
                FileGetIcon($szIconFile, $nIcon, $Sch[$i])
                If $nIcon <> 0 Then $nIcon = - $nIcon
                GuiCtrlSetImage(-1, $szIconFile, $nIcon)
            EndIf
        Next
    Next
EndFunc 

Func _runselecprogram()
    $ret = _GUICtrlListViewGetItemText($ListView)
    ShellExecute($path & "\" & $ret)
EndFunc

Func _Browser()
    $browserfile = RegRead("HKCR\http\shell\open\command","")
    ShellExecute($browserfile)
EndFunc


Func FileGetIcon(ByRef $szIconFile, ByRef $nIcon, $szFile)
    Dim $szRegDefault = "", $szDefIcon = ""
    $szExt = StringMid($szFile, StringInStr($szFile, '.', 0, -1))
    If $szExt = '.lnk' Then
        $details = FileGetShortcut($szIconFile)
        $szIconFile = $details[0]
        $szExt = StringMid($details[0], StringInStr($details[0], '.', 0, -1))
    EndIf
    $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 $szRegDefault = RegRead("HKCR\" & $szRegDefault & "\CurVer", "")
    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   ;==>FileGetIcon

I saw that when the user has no program selected the program would open the map (in this case m:), i put a "if and else" in the while loop to check if the user has selected a program. Now this works but its flickering. I added a sleep but that wouldnt help.

I alsow tried to get big icons, but that dosn't mather anymore. Its fine by this. Tnx for all the help so far.

Edit: mmzz, i can use this aswel: http://www.autoitscript.com/forum/index.ph...istView+Columns No need for a Button so no problem with Flashing/Flickering buttons.

Edit2: Nevermind, fixed it with dubbelclick. Tnx

Edited by xzaz
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...