使用AutoHotkey在当前目录打开命令行(cmd.exe)

原本是要使用HoeKey的,但是HoeKey最新的版本对Win7支持的不够好,%c(当前文件夹)参数无效,无奈之下使用AutoHotkey.使用AutoHotkey需要自行编写热键脚本,下面是在网上搜到一段脚本,测试通过.需要说明的是如果你的系统是英文则需要把脚本中的"地址"改为"Address".


SetTitleMatchMode RegEx
return

; Stuff to do when Windows Explorer is open
;
#IfWinActive ahk_class ExploreWClass|CabinetWClass

; create new text file
;
#t::Send !fwt

; open 'cmd' in the current directory
;
#c::
OpenCmdInCurrent()
return
#IfWinActive


; Opens the command shell 'cmd' in the directory browsed in Explorer.
; Note: expecting to be run when the active window is Explorer.
;
OpenCmdInCurrent()
{
; This is required to get the full path of the file from the address bar
WinGetText, full_path, A

; Split on newline (`n)
StringSplit, word_array, full_path, `n
; Take the first element from the array
full_path = %word_array1%

; strip to bare address
full_path := RegExReplace(full_path, "^地址: ", "")

; Just in case - remove all carriage returns (`r)
StringReplace, full_path, full_path, `r, , all


IfInString full_path, /
{
Run, cmd /K cd /D "%full_path%"
}
else
{
Run, cmd /K cd /D "C:/ "
}
}

  如果你不想安装热键工具,你也可以 在当前目录按Shift+鼠标右键, 你就可以看到类似"在此处打开命令行"的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修改下你的注册表,去注册表位置HKEY_CLASSES_ROOT/Directory/shell/cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT/Driver/shell/cmd和HKEY_CLASSES_ROOT/Directory /Background/shell/cmd 下的Extended键值去掉即可.

你可能感兴趣的:(auto)