此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ ?; ^0 H% V1 {8 B: v# w3 D4 v 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, j7 H1 D, w$ }: x% i# `) A 方式一:% [$ i- p7 K9 I# S; @) d
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ V& q( h, J; |! K" Z4 E; G
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* K% M3 B" [' s3 m3 K
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! a. y: H& e4 T" i! ] 方式二:. B' p5 ~: \& _5 l
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& l( ], n4 d4 B SetTitleMatchMode RegEx) a( ^' w% Z% e8 F
return
' w; I W9 G, B) |7 b& n ; Stuff to do when Windows Explorer is open) x# u+ t+ y. h2 m6 u j/ C
;
/ \) t4 O# [" t ?* e" T #IfWinActive ahk_class ExploreWClass|CabinetWClass% e# e: O$ @9 l. a7 F3 }
; open ‘cmd’ in the current directory
6 p. s# \( ]8 G* D- D- h* [ ;
" {) Q7 K0 n0 i/ W; }" _ #c::
! S- O* `: A1 T4 Y OpenCmdInCurrent()4 O% X) O3 g5 h' ~, K0 y! k
return
2 X' P1 P7 r6 k( O0 ]. R #IfWinActive
# A$ i2 k- ^# q* A4 e* D9 n ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
z3 f- }6 O2 h e i ; Note: expecting to be run when the active window is Explorer.
; E) O- A3 r! P- r0 l ;
+ L- }( N" Q5 v: o8 ^% m9 d OpenCmdInCurrent()
* g s' ^6 K4 R. j {& q0 E) \$ \* j% U5 y' L! j
; This is required to get the full path of the file from the address bar9 y! D" v; _+ Z9 b! k# c* D# L- s' N: _
WinGetText, full_path, A
- g( D" y) F: t* X6 j; W p ; Split on newline (`n)
/ q' X s9 J3 ?; k+ R. A4 O StringSplit, word_array, full_path, `n1 F7 U# ]! h' H* |
; Take the first element from the array2 T9 B8 s9 }: n; Y- B
full_path = %word_array1%
% Y8 r# O1 J8 {! w# {( X/ Z ; strip to bare address
5 X m7 y7 ?- b2 x. k! w0 M full_path := RegExReplace(full_path, “地址: “, “”)
0 R. V. s$ Z* A8 H" { ; Just in case – remove all carriage returns (`r)
0 }7 ~) ?3 r, A, O StringReplace, full_path, full_path, `r, , all" m0 @1 Q1 {5 ]$ h. M0 k' r2 c
IfInString full_path, \
; U( p! E; B& e4 ?+ A {
6 ?7 X: G; f4 p Run, cmd /K cd /D “%full_path%”) c5 W# c. f: _6 p! A# D3 j
}3 } B; X2 s+ b2 J. b
else
+ l. d, D0 `# z% m0 f7 b' L5 \ {* M4 o/ l/ \% L, ~1 A2 e
Run, cmd /K cd /D “C:\ ”6 d6 X9 ?7 x6 P: a3 U! F8 v
}$ ?9 ]: a( }4 \3 J
}
9 r) e" X. D) f, C 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ n# o( S& j2 R5 R* S 这段小代码肯能有两个你需要修改的地方
2 [* G9 T* c* f! b) K' } 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
2 F/ Z! Y/ H! R: @! o# F 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
% d0 Z- K) `6 @* h0 ~ |