使用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键值去掉即可.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Laurence 

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值