此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' ^/ C2 B9 ?' N. \& U
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
6 H9 g" ^+ U9 F, z2 c% A 方式一:
$ u, ]7 [( F6 w; ^ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 O" z! `! i" ]5 o9 {" E0 L
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ E/ D, o4 O w: k; U
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 b/ b0 \$ p) W
方式二:
( s q' C0 b2 \: v$ @ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 _# P3 c" n# p" s: \0 K* Y
SetTitleMatchMode RegEx, V! f1 ~2 B8 H/ P6 t: [ Y
return5 g( U# l& l; x0 P/ P
; Stuff to do when Windows Explorer is open
4 @% P9 Z8 a3 m8 L* a: c0 } ;
: P- k( M# g) t #IfWinActive ahk_class ExploreWClass|CabinetWClass
8 k+ E! {/ `( X2 s5 c ; open ‘cmd’ in the current directory8 o; G6 f: b! {1 g6 V
;3 o8 x k1 I. \- S" V. y1 a; ]
#c::: S+ q' q, U5 B; G: i, W# k
OpenCmdInCurrent()$ h1 y: f9 t( A0 E# W8 ]9 Q1 a$ H
return
* [2 G8 T$ a1 G7 B1 M' q #IfWinActive8 P& x; |3 S* l$ u0 H: p% b- ~
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 a r( ^: d' ~: s7 X: q ; Note: expecting to be run when the active window is Explorer.4 m" h" ~; j) W9 v2 `+ ~
;7 j6 w# q$ n; _% l8 d
OpenCmdInCurrent()
; z5 l, O3 z$ J0 ^ {: ^0 D+ K" H' `) F" j/ h
; This is required to get the full path of the file from the address bar
8 A- L2 Y. N- ^0 H% f; M% _" T4 ^ WinGetText, full_path, A
3 ~+ {! @6 ^! Y8 U% p& x3 D/ M, ~ ; Split on newline (`n)8 h3 E: `8 m6 D5 N! X/ {9 n
StringSplit, word_array, full_path, `n9 ]3 d3 J0 W2 g
; Take the first element from the array# s& _+ J; `) ]$ b" l( T. R3 h% i
full_path = %word_array1%
" t2 U) b1 c% v: A ; strip to bare address3 N0 ~, N v9 ~$ O5 j
full_path := RegExReplace(full_path, “地址: “, “”)
2 i: Q9 n+ c: |/ f; W ; Just in case – remove all carriage returns (`r)
+ i* E8 ?* }. x StringReplace, full_path, full_path, `r, , all2 w- p' D% [ ^8 h2 {8 R3 d* h) U
IfInString full_path, \% P9 S9 x k( v/ N& P
{
e# a- x, V4 H" K9 z+ i3 F5 P Run, cmd /K cd /D “%full_path%”6 k. t \ G. h6 ~& K
}
6 Q6 J8 }6 A: o- w. q else
5 {# i+ b- ?# S9 i {; F9 C" C0 k5 z% Y3 F
Run, cmd /K cd /D “C:\ ”7 Q$ _' }3 C. x* k5 T( B2 o# Z9 b
}1 `0 o- R$ [( ^* m
}
/ s N. R/ K$ `2 d# Z+ f) Y) P" J( u 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。8 t6 B& x8 i: `. T. l
这段小代码肯能有两个你需要修改的地方
& `9 C+ K7 y) @! B1 Y 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- c) Y8 k# l% e$ A 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: c% X B, a3 X+ o- e" | |