Skip to content

Instantly share code, notes, and snippets.

@hex128
Last active July 30, 2016 17:33
Show Gist options
  • Save hex128/89fd15ded19b232dd831 to your computer and use it in GitHub Desktop.
Save hex128/89fd15ded19b232dd831 to your computer and use it in GitHub Desktop.
/*
AutoHotkey_L: 1.1.00.00
Language: English
Platform: Win XP, Win 7
Author: rbrtryn
__________________________________________________________________________
| |
| Hotkeys Defined: |
| #c Opens a comand window to the current explorer window path |
|__________________________________________________________________________|
*/
#NoEnv
#SingleInstance Force
#NoTrayIcon
SendMode Input
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode RegEx
#IfWinActive ahk_class ExploreWClass|CabinetWClass|Progman
#c::
WinGetClass WinClass
If ( WinClass = "Progman" )
{
Run %ComSpec% /K cd /D "C:\"
Return
}
If ( InStr( "WIN_7,WIN_VISTA" , A_OSVersion ) )
{
Send {F4 2}
ControlGetText Path , Edit1
Send {Enter}
}
Else
{
; Windows XP doesn't know the Edit1 control exists if
; the Address Bar is hidden, so check if it exists and temporarly
; show the Address bar if needed. Temporarly showing the Address bar
; will register the Edit1 control, which contains the path.
ControlGetPos Edit1Pos , , , , Edit1
If ( !Edit1Pos )
{
PostMessage 0x111 , 41477 , 0 , , A ; Show Address Bar
Sleep 100
PostMessage 0x111 , 41477 , 0 , , A ; Hide Address Bar
}
ControlGetText Path , Edit1
}
If ( InStr( Path , ":" ) )
Run %ComSpec% /K cd /D "%Path%"
Else
Run %ComSpec% /K cd /D "C:\"
Return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment