此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, s* T9 u" @+ k) U# u- V( L
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
" {. K) [! V% J ]+ C 方式一:
- u9 }& \$ p- k: h 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 a B* k# l) s1 n- |+ s1 L
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ O- H* w, b' H6 d' z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ R) d& ?, ]% Z$ p0 v3 E* D 方式二:" b8 Q9 T- [' `4 H' q7 k/ i3 u
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 ^1 ^2 h2 h9 W2 C# M
SetTitleMatchMode RegEx6 n' N6 H8 K. C6 @9 E/ e; u8 }! }
return! c: H3 @9 h+ m; `$ y
; Stuff to do when Windows Explorer is open8 A* |% m8 @( O' w8 v$ F
;
: _2 t+ H9 X; F" J4 c6 Q& E/ W4 r+ O #IfWinActive ahk_class ExploreWClass|CabinetWClass/ Q/ L" x3 V w5 r* c! I8 @" U4 }
; open ‘cmd’ in the current directory
" F# }* I& ~5 {# ?, ?/ p2 | ;
W) z6 f% W& ^/ K8 e9 O% I6 e2 x #c::
3 k9 }" J6 h+ }4 C OpenCmdInCurrent()
+ v t0 G- I0 ^. Y return4 a/ T( O0 j' |) M. ]+ h/ ~
#IfWinActive
1 k- W/ _! m/ W7 ^4 J* E ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 A' H+ N% I. }; ^, ^
; Note: expecting to be run when the active window is Explorer.
& Z& }2 E- j9 S6 W8 t2 M7 G ;% v0 [) H) `: e( a0 I7 K. n
OpenCmdInCurrent()
+ J2 N" B; J% D1 K3 S9 I. a {
- h) d0 Y! R8 E2 \% l/ x5 w ; This is required to get the full path of the file from the address bar
, \( |: C v3 E# u7 p9 h0 P WinGetText, full_path, A
6 X: B* k( R( J- K& u, u ; Split on newline (`n)4 Z4 O8 `: q% i) k
StringSplit, word_array, full_path, `n
. T2 H j) Z1 Q0 u ; Take the first element from the array$ {" ~9 {. n9 Z! k
full_path = %word_array1%
" L" V0 L# T4 N' @ ; strip to bare address
& l! V8 a; c# e5 C/ T P. k full_path := RegExReplace(full_path, “地址: “, “”)
7 X7 Y0 [' L7 k* [. G ; Just in case – remove all carriage returns (`r)
: w( n' e% k# H1 B& ~; Y# n StringReplace, full_path, full_path, `r, , all
! D [) x; Z5 ]; z. J0 n+ ?& { IfInString full_path, \" M6 _ ^7 m4 S
{
# x+ C& S' V* H& o/ W" B Run, cmd /K cd /D “%full_path%”( x) d1 }* T L) U
}+ J& ^7 K; |" Z
else) D D- D; a. l' B5 C) m0 k
{7 S! j; d1 ^5 o. }2 ?" K
Run, cmd /K cd /D “C:\ ”" E6 B, T+ E0 x2 C
}
% u0 e4 \) j2 V$ [; \ }
$ U. R; T2 r. L% n# T* \8 H" _! A 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。, d9 Y* `, _; z+ K2 @+ F
这段小代码肯能有两个你需要修改的地方- Z6 i2 T3 k" X+ B
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ l# z- u( t T
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
6 v; J- e i/ J4 X; b; Y2 W1 n |