;------------------------------------------------------------NavigateDialog(strPath, strWinId, strClass);------------------------------------------------------------/*Excerpt from RMApp_Explorer_Navigate(FullPath, hwnd="") by Learning Onehttp://ahkscript.org/boards/viewtopic.php?f=5&t=526&start=20#p4673*/{if(strClass ="#32770")if ControlIsVisible("ahk_id ". strWinId,"Edit1") strControl :="Edit1"; in standard dialog windows, "Edit1" control is the right choiceElseif ControlIsVisible("ahk_id ". strWinId,"Edit2") strControl :="Edit2"; but sometimes in MS office, if condition above fails, "Edit2" control is the right choice Else; if above fails - just return and do nothing.{if(blnDiagMode) Diag("NavigateDialog","Error: #32770 Edit1 and Edit2 controls not visible")return}ElseifInStr(strClass,"bosa_sdm_"); for some MS office dialog windows, which are not #32770 classif ControlIsVisible("ahk_id ". strWinId,"Edit1") strControl :="Edit1"; if "Edit1" control exists, it is the right choiceElseif ControlIsVisible("ahk_id ". strWinId,"RichEdit20W2") strControl :="RichEdit20W2"; some MS office dialogs don't have "Edit1" control, but they have "RichEdit20W2" control, which is then the right choice.Else; if above fails, just return and do nothing.{if(blnDiagMode) Diag("NavigateDialog","Error: bosa_sdm Edit1 and RichEdit20W2 controls not visible")return}Else; in all other cases, open a new Explorer and return from this function{ComObjCreate("Shell.Application").Explore(strPath); http://msdn.microsoft.com/en-us/library/windows/desktop/bb774073%28v=vs.85%29.aspxif(blnDiagMode) Diag("NavigateDialog","Not #32770 or bosa_sdm: open New Explorer")return}

;===In this part (if we reached it), we'll send strPath to control and restore control's initial text after navigating to specified folder===ControlGetText, strPrevControlText,%strControl%, ahk_id %strWinId%; we'll get and store control's initial text first

;=== Avoid accidental hotkey & hotstring triggereing while doing SendInput - can be done simply by #UseHook, but do it if user doesn't have #UseHook in the script ===If(A_IsSuspended) blnWasSuspended :=Trueif(!blnWasSuspended)Suspend, OnSendInput,{End}{Space}{Backspace}{Enter}; silly but necessary part - go to end of control, send dummy space, delete it, and then send enterif(!blnWasSuspended)Suspend, Off

Sleep,70; give some time to control after sending {Enter} to itControlGetText, strControlTextAfterNavigation,%strControl%, ahk_id %strWinId%; sometimes controls automatically restore their initial textif(strControlTextAfterNavigation <> strPrevControlText); if not ControlSetTextR(strControl, strPrevControlText,"ahk_id ". strWinId); we'll set control's text to its initial text

;------------------------------------------------------------ControlIsVisible(strWinTitle, strControlClass)/*Adapted from ControlIsVisible(WinTitle,ControlClass) by Learning Onehttp://ahkscript.org/boards/viewtopic.php?f=5&t=526&start=20#p4673*/;------------------------------------------------------------{; used in NavigatorControlGet, blnIsControlVisible, Visible,,%strControlClass%,%strWinTitle%

Just to make my comment more clear, you can use command like ControlGetText and ControlSetText to save and change the current dialog box folder. The Send key itself is used only to press "Enter". This could be relatively simple. But the longer approach described by Learning One in viewtopic.php?f=5&t=526&start=20#p4673 is much safer.

Of course, if you are doing something for yourself (I mean, you don't plan to distribute your code to other users), you could work this out using only Send and Sleep commands.

EDIT (2014-09-06): Send, c:\delete#me does not work only because # is a AHK special character when used with Send. The command works if you add the {Raw} option: Send, {Raw}c:\delete#me. See comments from Lexikos belo for more about this.

JnLlnd, I came across your posts while searching for something else, and thought I'd look into your issue. However, window.Navigate("C:\C#Projects") works just fine for me on Windows 7. It also works with "file:///C:/C#Projects". Your Send code fails because # is the modifier symbol for the Win key. You can use {#} or SendRaw c:\delete#me`n (not {Enter}) instead.

lexikos wrote:Your Send code fails because # is the modifier symbol for the Win key. You can use {#} or SendRaw c:\delete#me`n (not {Enter}) instead.

Thanks for jumping in Lekikos. Yes, I realized that later in my AHK learning curve . Just forgot to update this thread about it.

lexikos wrote:However, window.Navigate("C:\C#Projects") works just fine for me on Windows 7.

You script also worked for me (after I adapted window.LocationName = "Computer" to my environment. But could you try the following and tell me if Alt-2 is running well for you? For me, it still produced an error. Would it be related to # being a special AHK char?

Apparently it only works if there is no slash after the hash. (Edit: Reading your Stack Overflow post, I see you already figured that out.)

Would it be related to # being a special AHK char?

# is special only for Send and hotkeys. No character in a quoted literal string has special meaning, except ` and ".

When a message box from "Windows Explorer" appears saying that it cannot find "file:///C:/delete#me/", that clearly shows that Windows Explorer is showing the error message, not AutoHotkey, and that Windows Explorer received the proper file path, since it is shown in the error message. One can therefore conclude that the problem lies with Windows Explorer.

This would need adjustment for systems without the "Display the full path in the title bar" option enabled.

Although Run %Path% should be reliable, it discards the (back/forward) history. Assuming you already have an Explorer window in the foreground that you want to open the folder in, this approach seems to be fairly reliable:

Hum... Interesting. So much work for something that should just be working in the first time... I suppose this is not the first time you have to work that hard around a Windows bug

I adapted my code to use SendInput command with {Raw} option instead of the ControlSetText approach that is now irrelevant. I also use your regex instead of a simple InStr. This will limit the use of the workaround to the cases where there is a \ after the #.

OK, unfortunately still a problem if the folder has a # in the first 6 characters of any of the subfolder names. Is it possible to assign a special folder ID to the folder with the hash, and then put that into Navigate()?

you can navigate from folder 1 to 2 by creating and invoking a lnk file inside folder 1,if you can't create a lnk in the protected/special folder,you could navigate to a go-between folder and create the lnk there,I don't know of a way to check whether the current folder is protected/special or not,so I could just always use the go-between folder

anyway you've got me hooked on this problem,I posted some code at the Stack Overflow link