此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
( b/ ]( R$ L. b0 v+ S- N1 g, {2 s; i 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 x8 @: P o7 B 方式一:
2 V1 t5 p! R7 P8 q* | 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 Y& k, w2 [1 `8 Z$ d( m; `
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和2 V* k6 V6 r/ A! @3 v
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。& g0 O {0 d7 g
方式二:; ~4 |( r2 U) z& W# p; Q4 G$ ]
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
3 M6 i. r. q- X* `8 u) } Z SetTitleMatchMode RegEx* t: U' {& @ ?0 Y! R
return
# c* r/ J- b' x ; Stuff to do when Windows Explorer is open
* T7 }: _' l/ h ;3 W2 I2 J a! w: Z, |! Q X! V9 a
#IfWinActive ahk_class ExploreWClass|CabinetWClass
! X: N- [3 |9 t1 \- e7 h ; open ‘cmd’ in the current directory
' \8 p; Y; @) P' c: t ;
: h+ S- i- u* D #c::; a; B- S8 d: }
OpenCmdInCurrent()
$ U; D' F# q) t( a return6 d p$ l, T5 ^) n; p6 A1 g
#IfWinActive
1 D3 g# @) N! y/ }( E ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* o. |4 C# e( {' W6 `: o
; Note: expecting to be run when the active window is Explorer.
3 u5 C4 N5 B1 M% V8 l3 c ;* m1 O& ^5 i6 F9 l. u8 e5 N( Z( a
OpenCmdInCurrent()
* A1 o) s- n; m) B {7 |$ ]3 s/ k+ Z% j$ C& y# \' J: T
; This is required to get the full path of the file from the address bar: M' t9 D4 Z5 Y) `
WinGetText, full_path, A
# h3 a- m$ ~, @( u) ^ ; Split on newline (`n)
$ ~8 M5 ?1 y5 { ] StringSplit, word_array, full_path, `n
E* W( O2 h" F/ i. q ; Take the first element from the array
8 f; y& U s& l/ z$ x& r% e full_path = %word_array1%8 w7 C: j( l) {- b, X
; strip to bare address
2 X# @1 Y. q% g- p0 ~7 `: D full_path := RegExReplace(full_path, “地址: “, “”)
. P9 p- O. p/ @3 u7 T8 k2 B! ` ; Just in case – remove all carriage returns (`r)
8 i+ f9 y- g. G) R( H StringReplace, full_path, full_path, `r, , all
. g6 d1 a7 Y1 X ]) n% j IfInString full_path, \
& S; t- }" i* l" T {! v3 c& m3 j6 r
Run, cmd /K cd /D “%full_path%”. S+ U3 C( Y7 }: ~# @0 ^0 q" Y" y& w
}# m1 n% Q$ F T9 A. i" z& X
else
; B2 y: s3 j0 U2 s- j {' J- d' T4 d( r: y
Run, cmd /K cd /D “C:\ ”
9 S* u1 z! p( [0 c& N# a% ^1 x }. Q% y: Q/ }5 t. Q. e% Q, m8 q
}
6 \: _" R" L! x6 r, r$ t 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: t( p F3 ?& Z/ ^4 | 这段小代码肯能有两个你需要修改的地方
/ `; t& b% |+ B$ q+ Q4 m: f* ~9 C 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
7 Q4 F7 j: l; `' w 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 g- P+ o8 A+ c! @+ g( u |