Jump to content

FileOpenDialog


Bert
 Share

Recommended Posts

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?

Link to comment
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
Link to comment
Share on other sites

  • 6 months later...

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...