Jump to content

A problem I'm having with FileSelectFolder


Recommended Posts

I'm using FileSelectFolder in a script I'm writing for my own use, but I've noticed that if I use optional flag 4 with it, that's the option that allows you to type the folder name, I can't get the folder path I type in. If I click on the C: drive, the edit control populates with the C: drive name, I type in after it \Users\username\...

Every time I type in the "\" character it shows me the folders under the folder listed like it's supposed to, so that I can drill down to the folder that I want to get to. Seems simple enough, except that even after I've typed in the path to the folder I need and hit the OK button, all the function is returning is the C: drive and completely ignores what I type in the edit box.

I'm currently using this on Windows 7 x86, I don't know if this is a Win7 idiosyncrasy or if FileSelectFolder just ignores everything typed into the Folder Path box? Is this a bug with the function, am I expecting something to happen that works differently than I expect, or am I just doing something wrong?

$Text = FileSelectFolder("Open", "", 5)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Text = ' & $Text & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

This extremely simple example of the process should explain what I'm seeing or not. Run the script, start by clicking on a drive letter and then adding folder names by adding a "\" to the end of the current name, or just type in a valid path, and hit OK and see what's returned in the Console window. Please let me know what is going wrong here, either with how I'm doing it, or what it's doing wrong. Thanks.

EDIT: I noticed that this only happens if I click on a folder or a drive letter and then start typing in the following folder names. It doesn't happen if you just type in the full folder path name without clicking on anything.

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

...Seems simple enough, except that even after I've typed in the path to the folder I need and hit the OK button, all the function is returning is the C: drive and completely ignores what I type in the edit box.

When you get the drop down of paths to choose from and you have the path already in the edit control, then you need to the press "ESC" key to close the drop down and then press the "Enter" key. If you do not press the "ESC" key while the drop down exists and you press the "Enter" key, then it accepts the default which in your case is "C:".

I test this on VirtualDub for opening a directory to process and it does the same thing. It is one of those Windows concepts that you may need to obey to get it to work.

Link to comment
Share on other sites

That doesn't work for me. If I hit ESC when the path is in the edit box, and then hit OK, I still get the folder/drive that I clicked on, and not what's in the edit box.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

That doesn't work for me. If I hit ESC when the path is in the edit box, and then hit OK, I still get the folder/drive that I clicked on, and not what's in the edit box.

Press "ESC" is to close the drop down if it is open is what I am stating.

If I press "Enter" key while the drop down is showing, then I get the default path in the Msgbox(). If I type the path, ignoring the drop down and the drop down disappears, and then press "ESC", then I get a Msgbox() with nothing in it. If I type the path, close the drop down with the "ESC" key and then press the "Enter" key then I get the path that I typed shown in the Msgbox().

So it seems to be what you do at which stage of the process, produces the final result . I did not test with mouse actions as it may imply both keyboard actions and mouse actions which can create even more combinations to test and explain.

Link to comment
Share on other sites

The sequence of events that I'm doing to get the issue I'm experiencing is like this.

1) Run the script

2) Click on the C: drive in the dialog box

3) Click in the Edit box without clearing the contents of it

4) Start typing in the rest of the path name

5) No matter what I type in the edit box after clicking on a drive, or a folder on that drive, is ignored when I hit Enter,

it doesn't matter if I hit Escape, or Enter, or whatever, the contents of the edit box isn't passed to the variable if

I click on anything before typing. I just get the item clicked returned to the variable. If I type the full path name in

the edit box (ex. C:\Users\username\(...)) I get the full path, but not if I click on anything and add to the path in the

edit box.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

What does the text in the box look like before and after you add the path? You are not leaving the disk name and other stray text in the box, are you?

:huh2:

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

I'm adding to the path that's already in the edit box

For example I click on the C: drive in the FileSelectDialog box, the Edit box on that screen now contains the C: drive, I add a backslash, the drop down populates with the files and folders on the root of the C: drive. I then select one of the folders in that list, in this example the Users folder so that the edit box now shows c:\users. Add another backslash to the end of that line and I now have the users folders listed etc. At this point, I've selected the folder I want to select, and click OK, I get the return value of the C: drive and nothing else. Another example, I click on the C: drive, then on the Users folder, and then start typing from there. The return value I get at that point is the C:\Users folder rather than what is showing in the edit box.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

That's what I was getting at. If the stray "helper" text is still there, it invalidates the string. On selecting the C: drive on Vista or Win7 I get "Local Disk (C:)". If I just put a backslash at the end of that it shows me the list of subdirectories in a context (i.e. Downloads), and I wind up with "Local Disk (C:)\Downloads", which is plainly an invalid path spec. As far as I can tell, that's stupid MS behavior, not AutoIt's.

:huh2:

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

I get the same thing, but I also get the issue showing up if I click on another folder name as well and start typing.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

This appears to be a Windows API function controlling these events with the FileSelectFolder() dialog. AutoIt calls the API function and waits for the return. So I am not sure what further discussion is going to achieve.

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