此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。0 |8 ^' r% A, {. c$ w
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 {0 A# u4 U5 P- m9 H" D8 d- u* [) c
方式一:9 o* R Y2 F b' b
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 s8 w ^6 U) w0 c' R2 X
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 t$ z% V& h- \ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 h5 Y3 W: ~0 n) F% T" }1 c9 b
方式二:% q2 d0 ]& s9 ` n4 U, V
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:- S' M" Z0 R( `4 P! q) X
SetTitleMatchMode RegEx
4 K. h8 S; `- ^, w! } return- M- V" G8 G( z7 m: }! B1 b
; Stuff to do when Windows Explorer is open
3 J9 w( c8 ]6 m. K! D$ C$ |6 q ;
8 n( C$ s% C C D2 |2 e #IfWinActive ahk_class ExploreWClass|CabinetWClass
B" ?5 Y. }, K6 e3 ? ; open ‘cmd’ in the current directory
4 K; q* t6 j$ @% {) {' q5 p. W ;$ e0 C1 [8 L8 G% ]# O S W9 o
#c::4 x, S# A( m' _0 Q7 @7 t" X
OpenCmdInCurrent()
6 B# G& D& E, F: H return
6 J/ B, L" ^+ {4 I; X/ E #IfWinActive
! i( F% m( l4 U6 d, y2 D ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; D+ W+ M- r' f& o9 ]: M, Y ; Note: expecting to be run when the active window is Explorer.
1 F K3 j2 a& ` ;) u9 n$ ]1 I& z
OpenCmdInCurrent()
! ~3 P v6 O/ o, m( S5 g- b4 W Q; B {0 r& ~; c! }1 l/ i
; This is required to get the full path of the file from the address bar
4 L L% |4 S" h- X4 o8 f+ ? WinGetText, full_path, A' L6 T. a* w4 `4 [" u
; Split on newline (`n)
. l- w# z2 j8 t% Y StringSplit, word_array, full_path, `n5 g8 f7 R7 A, r7 `' L5 y. L. ?
; Take the first element from the array! a5 O# O$ X x
full_path = %word_array1%
- l2 z5 z# f1 X, ^% n* l ; strip to bare address
, C9 `: I1 P2 y9 d Z3 t0 |4 h full_path := RegExReplace(full_path, “地址: “, “”)
/ M9 D: d* P: a- K5 y# g2 c ; Just in case – remove all carriage returns (`r)
5 k0 `: ?. i/ G' s StringReplace, full_path, full_path, `r, , all
. U+ w6 x! J. `# e9 Q ] IfInString full_path, \) V0 G5 x. U* A( V
{
5 I8 ~6 h7 L; Z9 H" G) P Run, cmd /K cd /D “%full_path%”
/ a3 ` |( A9 p3 ?! c E) v }
0 _% ^# T# Y* o h: i else
l- U9 Z Z& B6 r6 v {
, k2 V8 ^8 E5 L/ c+ o Run, cmd /K cd /D “C:\ ”& [) z# {; j7 {% e1 G# W* r. o L C
}4 ]; B' N ]4 |/ @
}
: L' o! Z# G8 |/ o$ f 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) k) G6 L0 w7 u& {
这段小代码肯能有两个你需要修改的地方
! b1 h! V* W- ?2 T: \6 Q1 A 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 r |9 f' X/ L! B$ o3 u( s+ B 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ R( C) D# H6 T |