Sign in to follow this  
Followers 0
aseitz

Help with a basic window

8 posts in this topic

#1 ·  Posted (edited)

Hey Guys,

I rock AutoIT when it comes to Console UI but I suck at the Windows stuff. I am trying to make a Window that opens up and displays the contents of a folder. The folder will contain folders and files and I need the Window to display these items. Using Windows Explorer is not an option because I am attempting to make the window secure and do not want all the fluff of the Windows Explorer.

This is probably stupid simple but I am thoroughly stumped. The Window also should not have any controls on it other than Min/Max/Close. Double-Clicking the items should either move to the next folder or launch the file that was clicked.

Thanks!

Edited by aseitz

Share this post


Link to post
Share on other sites



So you want _FileListToArray() to get you a list of contents, maybe do it twice to get separate lists of folders and files. The control in your window would be either GuiCtrlCreateList() for a simple, 1-column list, or GuiCtrlCreateListView() for a multi-column list.

That, plus the examples in the help file should get you started. When you get stuck, post what you have for more help.

:blink:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

So you want _FileListToArray() to get you a list of contents, maybe do it twice to get separate lists of folders and files. The control in your window would be either GuiCtrlCreateList() for a simple, 1-column list, or GuiCtrlCreateListView() for a multi-column list.

That, plus the examples in the help file should get you started. When you get stuck, post what you have for more help.

:blink:

Hey thanks for the reply. The part I am stuck on is preventing me from posting code... I am unable to find a sample of a window that is used to browse files "explorer" style. If I could use a tree-view or file-open type of thing, I would not be stuck. I just can't find a sample of an "windows explorer style" (not internet explorer) file browser for files.

If you have any suggestions, I would love to hear them.

I am / have been browsing the forums through the sample GUI and using the search with no real results. The sample windows that come with the AutoIT editor are not the correct style either. In fact it seems everything is covered in the samples - except what I am trying to find.

Share this post


Link to post
Share on other sites

aseitz,

a sample of a window that is used to browse files "explorer" style

Have you looked at FileOpenDialog? ;)

If you want to make a custom version, you could look at KaFu's Tri-State TreeView here. :blink:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Hey thanks for the reply. The part I am stuck on is preventing me from posting code... I am unable to find a sample of a window that is used to browse files "explorer" style. If I could use a tree-view or file-open type of thing, I would not be stuck. I just can't find a sample of an "windows explorer style" (not internet explorer) file browser for files.

If you have any suggestions, I would love to hear them.

I am / have been browsing the forums through the sample GUI and using the search with no real results. The sample windows that come with the AutoIT editor are not the correct style either. In fact it seems everything is covered in the samples - except what I am trying to find.

Attached is a very crude mock-up of what i am looking for.

Am I just going to have to present a blank window ... align a white background and parse and place icons manually? Seems a lot of work for some windows hook that must be there already.

post-40825-12796554536793_thumb.jpg

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Ok this seems to me to be the hardest way to do it - but here is what I have. If your executing the code directly, create a @WindowsDir\System32\Icons Folder and toss one link in there. The code is only worrying about one link at the moment because that part of the logic is going to be easier for me to deal with than the initial creation of a functional icon.

I can't seem to figure out how to make a real icon ... just a fake one.

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Local $ICON_ROOT = @WindowsDir & "\System32\Icons"
Local $ICON_PAD = 10    ; Padding Between Icons
Local $ICON_X = 20      ; Start Point For Icons X Position
Local $ICON_Y = 10      ; Start Point For Icons Y Position
Local $LABEL_X = 10     ; Start Point For Label X Position
Local $LABEL_Y = 45     ; Start Point For Label Y Position

; Set our search to search for any file name.
$Search = FileFindFirstFile($ICON_ROOT & "\*.lnk")

; Start a loop to loop through the Icons Folder.
While 1
    If $Search = -1 Then
        ExitLoop
    EndIf

    ; Fill in our File variable and move on
    $File = FileFindNextFile($Search)

    ; This really will never happen
    If @error Then ExitLoop

    ; Set some variables to be used for file manipulation
    $FullFilePath = $ICON_ROOT & "\" & $File
    $FileAttributes = FileGetAttrib($FullFilePath)


    ; Skip if we are looking at a Directory
    If Not StringInStr($FileAttributes,"D") Then
        ; Let's Pull properties of it
        $Link=FileGetShortcut($FullFilePath)
        $LinkName = StringTrimRight( $File, 4)
    EndIf
WEnd

; GUI
GuiCreate("Application Launcher", 640, 480)
$icon = GUICtrlCreateIcon($Link[0], $Link[5], $ICON_X, $ICON_Y)
GuiCtrlCreateLabel($LinkName, $LABEL_X, $LABEL_Y, 100, 20)

; GUI MESSAGE LOOP
GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

AppLauncher.au3

Edited by aseitz

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

A bunch of Labels...? :P

What if you started from something more like this, instead:

#include <GuiConstantsEx.au3>

Global $ICON_ROOT = "C:\Program Files\AutoIt3\Include"
Global $hGUI = GUICreate("Application Launcher", 640, 480)
Global $idLV = GUICtrlCreateListView("Name                |Attrib          ", 10, 10, 620, 460)

; Set our search to search for any file name.
$Search = FileFindFirstFile($ICON_ROOT & "\*.au3")
    If $Search = -1 Then
        MsgBox(16, "Error", "No .au3 files found.")
        Exit
    EndIf

; Start a loop to loop through the Icons Folder.
While 1
    $File = FileFindNextFile($Search)
    If @error Then ExitLoop

    $FullFilePath = $ICON_ROOT & "\" & $File
    $FileAttributes = FileGetAttrib($FullFilePath)
    If Not StringInStr($FileAttributes, "D") Then
        ; Let's Pull properties of it
        $Link = FileGetShortcut($FullFilePath)
        $LinkName = StringTrimRight($File, 4)
        GUICtrlCreateListViewItem($LinkName & "|" & $FileAttributes, $idLV)
    EndIf
WEnd

; GUI MESSAGE LOOP
GUISetState()
While GUIGetMsg() <> $GUI_EVENT_CLOSE
WEnd

:blink:

P.S. If you learn to use the GuiListView.au3 UDF, you can icons, checkboxes, and all kinds of geeky coolness to your ListView.

;)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

A bunch of Labels...? :P

What if you started from something more like this, instead:

#include <GuiConstantsEx.au3>

Global $ICON_ROOT = "C:\Program Files\AutoIt3\Include"
Global $hGUI = GUICreate("Application Launcher", 640, 480)
Global $idLV = GUICtrlCreateListView("Name                |Attrib          ", 10, 10, 620, 460)

; Set our search to search for any file name.
$Search = FileFindFirstFile($ICON_ROOT & "\*.au3")
    If $Search = -1 Then
        MsgBox(16, "Error", "No .au3 files found.")
        Exit
    EndIf

; Start a loop to loop through the Icons Folder.
While 1
    $File = FileFindNextFile($Search)
    If @error Then ExitLoop

    $FullFilePath = $ICON_ROOT & "\" & $File
    $FileAttributes = FileGetAttrib($FullFilePath)
    If Not StringInStr($FileAttributes, "D") Then
        ; Let's Pull properties of it
        $Link = FileGetShortcut($FullFilePath)
        $LinkName = StringTrimRight($File, 4)
        GUICtrlCreateListViewItem($LinkName & "|" & $FileAttributes, $idLV)
    EndIf
WEnd

; GUI MESSAGE LOOP
GUISetState()
While GUIGetMsg() <> $GUI_EVENT_CLOSE
WEnd

:blink:

P.S. If you learn to use the GuiListView.au3 UDF, you can icons, checkboxes, and all kinds of geeky coolness to your ListView.

;)

Thanks for the help - I must be explaining this wrong. What I am trying to do is create a Window that shows a bunch of icons that can be used to launch programs. The icons are actual .lnk files. I can't seem to figure out how AutoIT creates Windows Icons. Any ideas?

post-40825-12797332540972_thumb.jpg

Edited by aseitz

Share this post


Link to post
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
Sign in to follow this  
Followers 0