Jump to content
Sign in to follow this  

FileopenDialog() InitDir Behavior Question

Recommended Posts



wow, it's been a while since i've posted in here (4+ years). it's good to be back and to see that AutoIt is going on strong.

Here's the behavior i'm trying to understand.

background: I have a specific Autoit application that invokes a fileopendialog. The initdir parameter is set to @scriptdir.

When running a single instance of the application, the fileopendialog behaves as expected. The fileopendialog window opens and the folder location is correctly set to the @scriptdir location (of that instance).

When running a second or third instance (where the exes themselves are located in a different location), the fileopendialog sets the initdir to one of the first two initdir (aka @scriptdir) locations.

this is a little frustating, and im not sure how to control this behavior, since i dont exactly know when and where @scriptdir is technically fetching its information.

I've tried assigning the @scriptdir setting to a user defined variable @curfolder in the begining of my script, which works well in scite, but not when compiled. I have several theories (one is that multiple instances somehow share the same variables/PID) but would like to get confirmation on what is driving this behavior.

I've also tried using @scriptfullpath.

Any help is appreciated. hopefully i've described the situation well enough, let me know if have not.

---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Share this post

Link to post
Share on other sites


Welcome (back) to the AutoIt forum! :)

I cannot reproduce the problem - when I run separate instances of a script using FileOpenDialog I always get the required initial folder regardless of what the other instances have selected or are using as a default:

HotKeySet("{ESC}", "On_Exit")

While 1
        $sInitDir = @ScriptDir
        $sPath = FileOpenDialog("Test", $sInitDir, "AU3 files (*.au3)")

Func On_Exit()

Can you see if this script acts correctly for you - and try to produce a reproducer script which shows your problem. :)


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


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

hmm yea, i can't get it to reproduce anymore.

Thanks, however.

---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

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  

  • Similar Content

    • Gringo
      By Gringo
      I'm trying to:
      -Select a file in a folder (to store it to an ini file)
      -Write the file on an ini
      -Copy files to the folder selected by the user
      instead of using FileOpenDialog then FileSelectFolder, I was wondering if it was possible to do the whole thing only with FileOpenDialog spliting the value returned in 2 variables. I got something like that for the first part (select a file and store it to an ini file)
      Local $message = "Select your executable" Local $pathk = FileOpenDialog($message, "C:" & "", "Select the executable you want to terminate (*.exe)", 1 + 4) Local $path = "None" ;ici je dois copier les fichiers $split = StringSplit($pathk, "\") $tokill = $split[$split[0]] If @error Then MsgBox(4096, "", "No Executable chosen") Else MsgBox(4096, "", $pathk & " Will be terminated " & @LF & @LF & "Press OK to EXIT ") IniWrite(@ScriptDir & "\path.ini", "Torun", "path", $path) IniWrite(@ScriptDir & "\path.ini", "Tokill", "pathk", $tokill) EndIf As you can see I manage to split the value returned by FileOpenDialog to have only the exe but as a noob I can't manage to get the path to copy the files I need to the same path.
      Any idea? ^^
    • PINTO1927
      By PINTO1927
      Hello guys,
      I'm working on this script:
      Case $BTN Global $URL = FileOpenDialog("IMPORT FILE", $DESKTOP, "ALL FORMAT (*)", 4) $DIR_DEST = "C:\DIR-WORK\list\IMPORT_DOC\" DirCreate($DIR_DEST) Local $LINE For $t = 1 To $URL[0] _FileReadToArray($URL[$t], $LINE) For $u = 1 To $LINE[0] FileCopy($URL[$u], $DIR_DEST) Next Next the selected files via OpenFileDialog must be copied to the folder $DIR_DEST.
    • rootx
      By rootx
      Why if I select only one file the array doesn't return the path?? And 4 multiple files return the row PATH? There is a mode to have in the same case signle or multiple selection the path included in the file name? THX
      #include <Array.au3> #include <File.au3> Local $spFile $mFile = FileOpenDialog("apri", @ScriptDir & "", "Images (*.iso)", 1 + 4 ) If @error Then ConsoleWrite("error") Else $spFile = StringSplit($mFile, "|") EndIf _ArrayDisplay($spFile)  
    • Slym
      By Slym
      Hi there,
      There is something weird with FileSaveDialog. It takes approximately 8 seconds on my computer to return after clicking on OK.
      When compiling this exact code it looks faster but I still have this slow behaviour on another compiled software (LinuxLive USB Creator).
      $DEBUG_TIMER=TimerInit() $source_file = FileOpenDialog("Please choose an ISO image of LinuxLive CD", "", "ISO / IMG / ZIP (*.iso;*.img;*.zip)", 1,"") ConsoleWrite("It took "&Round(TimerDiff($DEBUG_TIMER)/1000,1)&" seconds to select ISO") Do you know what could cause this ?
      Thank you for your help
      PS : I'm still looking for AutoIT devs to help me on LinuxLive USB Creator. If interested, please contact me.
    • afzalw
      By afzalw
      I dont know what am I doing wrong, I want to run a .m file in the directory of my script its name is Matlabcode.m

      Run(@ScriptDir & "\Matlabcode.m", "", @SW_MAXIMIZE)