此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。- g$ z# e! s" i p) F6 l0 L+ F
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
; P9 n1 m; I$ s8 z$ |- `2 j 方式一:+ v* `# v5 j8 k l( K+ }0 ]
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 X/ t! P& ~5 J% }+ q0 ~ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 u6 H. J/ {5 ]2 ~) P
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
e$ n# \2 S P3 X 方式二:
, k% K; R5 Q" \: E/ \ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:) N& h) O2 e2 X% ?' S* s
SetTitleMatchMode RegEx4 S6 U- N# \ t9 E
return1 ?# c) C; I2 W+ j2 a. P! W
; Stuff to do when Windows Explorer is open
0 A7 e: W5 o1 Z ;
4 }4 K: |# E y: d Y& B #IfWinActive ahk_class ExploreWClass|CabinetWClass7 O, ?, ` b/ ?
; open ‘cmd’ in the current directory
8 A0 H0 ^& ]/ e) C" ^# a0 s ;* V' _; \6 J+ t9 T' o
#c::! b, P7 \3 R" G) x* z- |
OpenCmdInCurrent()
F2 d& R! O8 }# q+ g% P& G/ r5 F return
4 u+ K( n! N: C' V( A #IfWinActive
5 |% b& L' f- N& t ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.! \& L/ e' l, E
; Note: expecting to be run when the active window is Explorer.; e7 X4 o; t8 ]$ }& B2 m, S0 y* a
;
$ A" Q. v! b9 o. x OpenCmdInCurrent()$ P2 U8 v& T A+ x9 D
{! e$ o5 |/ I2 D) I& F8 U
; This is required to get the full path of the file from the address bar' F3 f* M1 H" u' v6 \* K. S9 W
WinGetText, full_path, A/ [6 z# q! ^: m6 `5 N A7 ^
; Split on newline (`n)4 a3 X. y8 z3 ^0 r( @# R
StringSplit, word_array, full_path, `n" a/ {7 @- Q7 X' |3 D% g
; Take the first element from the array& p% n4 ]* T# r) b
full_path = %word_array1%
5 B1 a# n9 X' I. c$ H ; strip to bare address
. l" c( \" H; }: d1 a. F5 K full_path := RegExReplace(full_path, “地址: “, “”)$ A2 i" D3 g/ k2 _8 A/ d9 \
; Just in case – remove all carriage returns (`r)( t5 o& C* U+ q0 T, N& ~
StringReplace, full_path, full_path, `r, , all% k3 ], c5 m0 B3 k9 ^. M. y
IfInString full_path, \
! |% L: K- U2 j; ~. s5 U4 [ {7 D( r: J# i5 m3 Q: X# U5 y
Run, cmd /K cd /D “%full_path%”: v# I* E& D' x, }
}& g4 N4 d. n) d7 Z2 I
else
, e- w% w5 Q! a4 p' G' \ {
x: R3 J, N% r7 v. l& H3 c Run, cmd /K cd /D “C:\ ”
" V# H! \+ ~2 K s2 H" B) H }
F( r3 D+ g7 j4 u, Y }7 w# L& Q5 z: S5 C% j, e' }3 D
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. s! S5 I% H* |$ I6 @# X( x3 x 这段小代码肯能有两个你需要修改的地方
0 x( ?2 t% b: R6 v* X; m! ~ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( {% u* G: W- C6 y5 c& s6 h: J' P 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( r4 t. A: {( n6 Y8 B% o1 B+ a
|