Sign in to follow this  
Followers 0
Bert

FileOpenDialog

4 posts in this topic

In learning Autoit, I used for the first time FileOpenDialog in one of my scripts. I found that it works well for what I needed it to do. However, I did notice a small problem. When I go to select a folder, I can select things like "My Computer", or "Network Places", or even the recycle bin. I know I can use CLSID to handle the problem, but that will take some doing. Does anyone have a snippit of code that weeds out these things so you can only select a folder? I'm working with another Autoit enthusiast to design a program, and I discovered this problem. We like to address it and have it fixed before we test the beta. Any thoughts?

Share this post


Link to post
Share on other sites



is this what your looking for

$var = FileSelectFolder("Choose a folder.", "")

phil

Share this post


Link to post
Share on other sites

not quite. When you use FileOpenDialog, you can select things like My Computer as a file if you have your desktop as the root. As a work around, I used My Computer as root, and the following code. It is somewhat messy, but it does do what I need it to do. If My computer or Control panel is selected, the user will get a error box, then is given the FileOpenDialog again to correct the error.

Case $msg1 = $Wlog1;Button to select file for log
            $chk = GUICtrlRead($Wlog2)
            GUICtrlSetState($Wbutton1, $GUI_ENABLE)
            $selectFDR = FileSelectFolder("Select path to folder where you want to keep log file", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 1 + 2 + 4, @HomeDrive)
            If $selectFDR = "My Computer" then
                MsgBox(0, "Error", "You must select a Folder or Drive", 3)
                $selectFDR = FileSelectFolder("Select path to folder where you want to keep log file", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 1 + 2 + 4, @HomeDrive)
            endif
            If $selectFDR = "Control Panel" then
                MsgBox(0, "Error", "You must select a Folder or Drive", 3)
                $selectFDR = FileSelectFolder("Select path to folder where you want to keep log file", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 1 + 2 + 4, @HomeDrive)
            endif
            if StringLen($selectFDR) = 0 then 
               GUICtrlSetData($Wlog2, $chk)         
            else 
                GUICtrlSetData($Wlog2, $selectFDR)
            endif

Share this post


Link to post
Share on other sites

where can i find a list of all the SID's for the different built in directories?

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