FaridAgl Posted January 19, 2014 Share Posted January 19, 2014 (edited) ConsoleWrite("Original working directory: " & @CRLF & GetCurrentDirectory() & @CRLF & @CRLF) FileSaveDialog("", "", "", 0, "") ConsoleWrite("Working directory after FileSaveDialog: " & @CRLF & GetCurrentDirectory() & @CRLF & @CRLF) FileOpenDialog("", "", "", 0, "") ConsoleWrite("Working directory after FileOpenDialog: " & @CRLF & GetCurrentDirectory() & @CRLF & @CRLF) FileSelectFolder("", "", 0, "") ConsoleWrite("Working directory after FileSelectFolder (It's just OK): " & @CRLF & GetCurrentDirectory() & @CRLF) Func GetCurrentDirectory() Local $avResult $avResult = DllCall("kernel32.dll", "DWORD", "GetCurrentDirectory", _ "DWORD", 0, _ "ptr", 0) If ((@error) Or ($avResult = 0)) Then Return SetError(1, 0, "") Local $tBuffer = DllStructCreate("CHAR[" & $avResult[0] & "]") $avResult = DllCall("kernel32.dll", "DWORD", "GetCurrentDirectory", _ "DWORD", $avResult[0], _ "ptr", DllStructGetPtr($tBuffer, 1)) If ((@error) Or ($avResult = 0)) Then Return SetError(2, 0, "") Return SetError(0, 0, DllStructGetData($tBuffer, 1)) EndFunc The above code demonstrates the situation. In the beginning the working directory is just fine. Then after FileSaveDialog it gets changed to the selected directory, also after FileOpenDialog it gets changed to the new selected dir. However FileSelectFolder is just fine and doesn't change the working directory. I guess it's that kind of bugs which you will not get noticed about but will ruin every single line of code which you write based on script's relative path. Edited January 19, 2014 by D4RKON3 http://faridaghili.ir Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 19, 2014 Moderators Share Posted January 19, 2014 D4RKON3,It is a Windows "feature" and not an AutoIt "bug" - and as they are all direct API calls there is not a lot that can be done about it. The fact that @WorkingDir changes on a successful return is mentioned in the Help file for FileOpen/SaveDialog. M23 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: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
KaFu Posted January 19, 2014 Share Posted January 19, 2014 Here's my work-around I use in AMT... Func _FileOpenDialog_Ex($sTitle, $sInitDir, $sFilter, $iOptions = 0, $sDefaultName = "", $hWnd = 0) #cs https://groups.google.com/forum/?hl=en&fromgroups=#!topic/microsoft.public.vc.mfc/HafQr4gIRY0 The problem is that GetOpenFileName changes the current directory to the last browsed one. The current directory and any of its parents cannot be deleted. #ce Local $sWorkingDir = @WorkingDir Local $sFilename = FileOpenDialog($sTitle, $sInitDir, $sFilter, $iOptions, $sDefaultName, $hWnd) Local $iError = @error FileChangeDir($sWorkingDir) Return SetError($iError, 0, $sFilename) EndFunc ;==>_FileOpenDialog_Ex 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) Link to comment Share on other sites More sharing options...
FaridAgl Posted January 19, 2014 Author Share Posted January 19, 2014 Melba23 Yes, you are right, I didn't checked that part of help file. KaFu Thanks, you gave me the idea. http://faridaghili.ir Link to comment Share on other sites More sharing options...
Ascend4nt Posted January 20, 2014 Share Posted January 20, 2014 Nice workaround KaFu.. I wasn't aware that the issue was documented, and have only seen it crop up intermittently. My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
Administrators Jon Posted January 20, 2014 Administrators Share Posted January 20, 2014 Hmm, if didn't realise that. I probably would have fixed it at the time, but it's probably a little too script breaking to do now. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
jaberwacky Posted January 20, 2014 Share Posted January 20, 2014 a little too script breaking to do now. Can we complain? We get it for free. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
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