此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
# Q# P4 x3 w% [. \ d9 n" v% v: i 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, L' s, |4 j' R5 ~
方式一:+ Y7 h2 x5 m: M' w8 }
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# V0 V9 a/ ` ]2 q7 ?% I {
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) e: _6 t$ T ^- \: I6 u8 \# w
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。' ~( u4 B3 T3 ~. c' J; @
方式二:8 C6 Y$ _$ F$ m& T4 F
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
! c5 Z5 M4 X: t SetTitleMatchMode RegEx Y3 ^% u) D3 k1 m7 o n
return% z8 s; K" ?3 I* \& _/ k$ @' _" A
; Stuff to do when Windows Explorer is open
% [# Z0 G% r) J% q6 g' F ;
6 {0 j& g# l9 b0 J; v% x! ?* Q #IfWinActive ahk_class ExploreWClass|CabinetWClass' i% F( c; X; I! H3 @6 O
; open ‘cmd’ in the current directory
& Z+ Z6 k2 M) S+ X1 x L! D/ j( `% F ;
& |& N: [' J7 v9 ^0 { #c::1 o" i7 a" @! O# w$ s
OpenCmdInCurrent()) H* K; d6 y+ \! |# C, c
return5 R* t& G0 s I+ m. B3 T2 q. v
#IfWinActive) X" |! o* E( ]3 K5 G# w; l* D
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
/ _/ K+ r7 _5 H& c) |) a6 S ; Note: expecting to be run when the active window is Explorer.# N; n' c* b$ R" _2 c& y
;
% y4 S. l5 P4 B I OpenCmdInCurrent(): l' f3 d4 m$ \- I! q$ u( ~2 [) {
{: T- S+ f# K; \' ]7 n9 A u
; This is required to get the full path of the file from the address bar
9 B, `* f7 J: i3 J WinGetText, full_path, A
& o# I I! J9 h( Y ; Split on newline (`n)1 ~* s8 a1 Q4 `9 e( J
StringSplit, word_array, full_path, `n
" F! J) p; W5 F6 U' N) N ; Take the first element from the array
6 d8 o; d' S9 D9 T! j full_path = %word_array1%# J0 ?7 g% ?( Y/ ^* k
; strip to bare address1 ]! R4 x3 I9 a# I
full_path := RegExReplace(full_path, “地址: “, “”), d& e# ~! k6 U0 w
; Just in case – remove all carriage returns (`r)
1 O% ^" O% v0 p2 A) C+ q StringReplace, full_path, full_path, `r, , all1 x6 v% U f% f) A6 w: M
IfInString full_path, \
0 x' ^- p f* o9 Y# X { g( S. ~0 d9 q! r6 r
Run, cmd /K cd /D “%full_path%”* I* t, d; v0 O
}. @4 q( [9 C5 Y! s% X, w
else) s! s( w. q& Q
{) s9 y' E4 O n: |/ |0 S9 R
Run, cmd /K cd /D “C:\ ”
/ g6 S2 E: \- v, c) [( W5 B- ` }
4 F( r' S3 u" K" L$ d* i2 l }! n; T4 Y' J1 ?- C) ~# b
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# N) E1 s+ G# X 这段小代码肯能有两个你需要修改的地方& q5 L' V) E- ^. k6 h \% o
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
2 b- H$ c# s5 e+ o 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 S3 B" s# B0 H: i; F |