Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Navigating Explorer directories


  • Please log in to reply
3 replies to this topic
AutoHotKeyGirl
  • Members
  • 1 posts
  • Last active: Feb 21 2014 01:09 PM
  • Joined: 17 Feb 2014

Hi. I know this is very basic, but here goes.

 

I would like to use AHK for one-step navigation to specific directories in Windows Explorer, either from an already opened Explorer window, or by launching a new Explorer instance.

 

I've looked for a script that does this, or can be modified to do this... I'm sure there must be several out there... but haven't found one.

 

Doing it from scratch, I assume that the FileSelectFolder command is involved. And that I would need either a separate script, or a separate routine in a master script, for each pre-set folder I wanted that kind access to. But in either case, though I'm fairly familiar with VBA macros in Word, I must acknowledge that rolling my own in AHK is pretty much beyond me.

 

All info and insight on this will be appreciated.

 

Thanks!



Masonjar13
  • Members
  • 1517 posts
  • Last active:
  • Joined: 16 Sep 2012

Explorer is the default handler for local addresses, so all you need to do is run the address. Run C:\


OS: Windows 7 Ultimate / Windows 8.1 Pro | Editor: Notepad++


GEV
  • Members
  • 1364 posts
  • Last active:
  • Joined: 23 Oct 2013

 

I would like to use AHK for one-step navigation to specific directories in Windows Explorer

 

In my experience, the quickest way to get to a specific or favorite folder in Windows Explorer using AHK is a hotstring.

A hotstring is an abbreviation that triggers or launches an action.
http://www.autohotke.../Hotstrings.htm

 

For example you can use the abbreviation cw to get to the directory C:\Windows
and cws for the directory C:\Windows\System.

 

In this case the AHK code looks like this:

::cw::
Run, C:\Windows
Return

::cws::
Run, C:\Windows\System
Return

For the command FileSelectFolder you can use this hotstring:

::FSF::
FileSelectFolder, OutputVar, , 3
if OutputVar =
    MsgBox, You didn't select a folder.
else
    Run, %OutputVar%
return

http://www.autohotke...electFolder.htm





kon
  • Members
  • 1652 posts
  • Last active:
  • Joined: 04 Mar 2013

Here is an example of navigating to a directory without opening a new window.
This checks if the active window is an explorer window. If an explorer window is active it will navigate to the desired directory using the active window, otherwise it will use Run.
 
 ; Hotkeys 1 & 2
1::NavRun("C:\")
2::NavRun(A_MyDocuments)

; http://msdn.microsoft.com/en-us/library/bb774094
GetActiveExplorer() {
    static objShell := ComObjCreate("Shell.Application")
    WinHWND := WinActive("A")    ; Active window
    for Item in objShell.Windows
        if (Item.HWND = WinHWND)
            return Item        ; Return active window object
    return -1    ; No explorer windows match active window
}

NavRun(Path) {
    if (-1 != objIE := GetActiveExplorer())
        objIE.Navigate(Path)
    else
        Run, % Path
}