GordonFreeman Posted June 9, 2014 Posted June 9, 2014 The Function FileOpenDialog only show init dir when i not select a file, when i select a file the folder of this file is the init dir. Theres an way to force FileOpenDialog to "respect" always the "Init Dir" parameter? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListBox.au3> #include <Array.au3> #include <File.au3> $hGUI = GUICreate("Form1",500,500,-1,-1) $hBtnGet = GUICtrlCreateButton("Test",400,400,100,25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hBtnGet $File = FileOpenDialog("Selecione um Arquivo",@ScriptDir,"All (*.*)",1) FileChangeDir(@ScriptDir) MsgBox(0,"",$File) EndSwitch WEnd Frabjous Installation
Jfish Posted June 9, 2014 Posted June 9, 2014 I am not sure I follow you. The initial directory is always what appears for me even if I select a file from a sub folder. Can you explain the problem a bit more? Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt
GordonFreeman Posted June 9, 2014 Author Posted June 9, 2014 (edited) The initial dir is @scriptdir = D: Then i selected a file in D:Music. When i close and click again the init dir will be D:Music instead of D:. And i can re-run script and will happens the same think Thanks for attention Edited June 9, 2014 by GordonFreeman Frabjous Installation
Jfish Posted June 9, 2014 Posted June 9, 2014 (edited) You need to use a fixed path not a macro and it will work. You can make it a relative path to your script - try that. Because the successful return changes the @workingdir @WorkingDir is changed on successful return. - the help file Edited June 9, 2014 by Jfish Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt
GordonFreeman Posted June 10, 2014 Author Posted June 10, 2014 Lol. Same code and now working properly. I just put the same code on a script in Desktop works, then i moved to D: and also works. Anyway, thanks. Frabjous Installation
Jfish Posted June 10, 2014 Posted June 10, 2014 worked for me on win 7 with the original code but not win 8 - from the desktop ... Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt
KaFu Posted June 16, 2014 Posted June 16, 2014 (edited) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Form1", 100, 100, -1, -1) $hBtnGet = GUICtrlCreateButton("Test", 10, 35, 80, 25) GUISetState(@SW_SHOW) Global $sInitDir = @ScriptDir While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hBtnGet ; http://msdn.microsoft.com/en-us/library/windows/desktop/ms646839%28v=vs.85%29.aspx ; OPENFILENAME structure ; lpstrInitialDir ; Windows 7: If lpstrInitialDir has the same value as was passed the first time the application used an Open or Save As dialog box, the path most recently selected by the user is used as the initial directory. If StringRight($sInitDir, 1) = "\" Then $sInitDir = StringTrimRight($sInitDir, 1) Else $sInitDir &= "\" EndIf ConsoleWrite($sInitDir & @CRLF) $File = FileOpenDialog("Selecione um Arquivo", $sInitDir, "All (*.*)", 1) MsgBox(0, "", $File) EndSwitch WEnd Edited June 16, 2014 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now