此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 m+ G$ |* b/ k& w 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 @0 V1 L# i' W/ `! I. d 方式一:
: J" A% t8 {0 L+ F 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( L6 h& ^: }; {) j3 ?2 l 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 ?$ v# @1 c r- n4 x+ E
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。& c6 S% ?0 z( `2 U$ d$ p4 ^, X( Q
方式二:
, W2 h3 Y" v: ? 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# _( W/ r0 X7 R5 p9 \ SetTitleMatchMode RegEx7 B3 O" E9 W$ t% o4 t$ c
return
+ v3 G! B2 c e, |! } ; Stuff to do when Windows Explorer is open3 W! z4 l: a7 n7 p" \8 j6 u
;
1 o' m* x& A' J #IfWinActive ahk_class ExploreWClass|CabinetWClass& u/ L1 |. |4 e4 T, L i% \9 _, n
; open ‘cmd’ in the current directory7 j! w1 c$ s+ L, m4 h+ H! h
;
. I9 g0 U8 l4 E7 o1 O" n7 z: ? #c::
( ^* _' ]) S# y OpenCmdInCurrent()
- H2 B# u( a m& {4 D return+ f W* x2 G( |/ B* j
#IfWinActive+ O& c7 `4 H3 G1 l/ v' n
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.! b' w- @# \1 I7 R5 N8 U8 j
; Note: expecting to be run when the active window is Explorer.
6 t; @; N& q5 G8 w$ w" ~5 G ;
1 [7 A( T: }9 Y! [& W j OpenCmdInCurrent(). W# H+ L/ S# u& r5 o. a. ? m
{) }# n: d1 n( ?: {% c
; This is required to get the full path of the file from the address bar
3 x, i5 t: Z# N WinGetText, full_path, A
) l! x5 y- {4 T" o' m ; Split on newline (`n)" o6 E& N1 I) B4 R, H
StringSplit, word_array, full_path, `n& G, E; k1 F& j# i: k
; Take the first element from the array2 ~- P+ a# c9 P5 a/ I9 [0 M
full_path = %word_array1%8 q; C. X' v+ E* t$ H `: a; u# X
; strip to bare address) ?( C2 h$ R. i
full_path := RegExReplace(full_path, “地址: “, “”)
7 W, N+ F0 o3 Z) ?) ]1 o6 v* Z ; Just in case – remove all carriage returns (`r)
4 P% D9 b& }' `7 T, n j/ C8 C7 b StringReplace, full_path, full_path, `r, , all: ]! E- l$ Y0 K: B1 f! d1 R6 T
IfInString full_path, \
7 |+ s: P& @6 P9 t2 O4 j {6 e3 `8 w1 v1 w
Run, cmd /K cd /D “%full_path%”" j4 M# c# P) b6 [
}: s: ^9 F6 X4 ?
else
& X, E% ?+ k5 F: z9 _* A( C3 R. K {
2 b+ D4 x* A3 u Run, cmd /K cd /D “C:\ ”6 @, c; t k8 r
}: H' l1 q5 O/ c
} c) T1 l- I6 j* E0 U
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 x& ]+ i/ o1 P
这段小代码肯能有两个你需要修改的地方
$ K7 h- u" F5 { G: K 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; L+ }" w/ s, J; x: r 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “7 Q, t& ]4 {6 G0 {
|