Sign in to follow this  
Followers 0
QGEN

Specify File Variable Window

4 posts in this topic

Hi All,

Long time AutoIt user here, but new to the GUI. I am trying to make a window show up with text, a text box and a button to browse the file system.

I am writing a script that will ask the user to specify several different file types and then copy them to a specified folder. Right now, I have a MsgBox command come up that says "Specify the IPA file." You then click on the OK button and it then has a FileOpenDialog command to assign the file name and path to a variable. What I'd like to do is have these two steps inside one window so that it shows the text "Specify the IPA file.", has a text box to display the current value of the variable, and then a file system browser button (exactly like what FileOpenDialog does except in a button form). Once you browse the file system and specify the file, it would then show up in the text box. You would then have OK and Cancel at the bottom of the window to move on to the next file specification, which would be a duplicate of the above.

I have searched for examples like this, but find nothing.

Any help is appreciated.

Best,

QGEN

Share this post


Link to post
Share on other sites



Simple example:

#include <GUIConstants.au3>

$Form1 = GUICreate("IPA Selector", 601, 124, 193, 125)
$Label1 = GUICtrlCreateLabel("Path:", 16, 8, 29, 17)
$Input1 = GUICtrlCreateInput("", 16, 32, 473, 21)
$Button1 = GUICtrlCreateButton("Select", 504, 32, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Run", 504, 80, 75, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $path = FileOpenDialog("Specify the IPA file", @DesktopDir & "\", "IPA (*.ipa)", 1 + 4 )
            GUICtrlSetData($Input1, $path)
    EndSwitch
WEnd

#include <ByteMe.au3>

Share this post


Link to post
Share on other sites

Genious.... Exactly what I needed. Amazing. Thank you!

Share this post


Link to post
Share on other sites

If you want to select multiple files and choose from a drop down list of what you selected:

#include <GUIConstants.au3>
#include <array.au3>

$Form1 = GUICreate("Form1", 601, 124, 193, 125)
$Label1 = GUICtrlCreateLabel("Path:", 16, 8, 29, 17)
$Input1 = GUICtrlCreateInput("", 16, 32, 473, 21)
$Button1 = GUICtrlCreateButton("Select", 504, 32, 75, 25, 0)
$Combo1 = GUICtrlCreateCombo("", 16, 80, 473, 25)
$Button2 = GUICtrlCreateButton("Run", 504, 80, 75, 25, 0)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $path = FileOpenDialog("Specify the IPA file", @DesktopDir & "\", "IPA (*.ipa)", 1 + 4 )
            GUICtrlSetData($Input1, $path)
            $pathSplit = StringSplit($path, "|")
            ;_ArrayDisplay($pathSplit)
            $list = ""
            For $i = 2 to $pathSplit[0] Step 1
                $list =  $list & $pathSplit[1] & "\" & $pathSplit[$i] & "|"
            Next
            GUICtrlSetData($Combo1, $list)
        Case $Button2
            $read = GUICtrlRead($Combo1)
            MsgBox(0, "", "You selected: " & $read)
    EndSwitch
WEnd

#include <ByteMe.au3>

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