此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 \/ w( b. x( }! K0 r
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 Y- z8 b4 w+ | d! U) D6 l 方式一:
$ o( e# A0 y9 x7 T% D 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ @* Y1 W5 R' u& G- Z" c! ~0 _
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* r+ \- h" _2 D5 N0 q
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- D$ H9 V' t3 a0 ~; E0 w3 v
方式二:2 [* d. C% \: F" C; `
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" _ @: E4 w4 K: b- x
SetTitleMatchMode RegEx
) J: l- E4 l7 D8 Q- g5 @% g return
4 s7 A/ I& Z0 t" Y2 f! H5 D! [6 ]1 P ; Stuff to do when Windows Explorer is open
9 @+ r* K3 h% _5 K ;
' x) k4 i0 s5 p$ j2 C/ b# b #IfWinActive ahk_class ExploreWClass|CabinetWClass
5 A4 a. R( |# S/ ~! {( z ; open ‘cmd’ in the current directory
4 R* @4 | d# b- R) A ;
f. M5 |0 M5 Z1 v1 V6 l8 a+ b #c::4 C0 s5 D/ @1 F. U$ r& V( B
OpenCmdInCurrent()
: x; {- C$ |' _6 r, ]# x a6 O return* q8 @- L$ I. K- Y4 P% P
#IfWinActive
+ x9 p, r4 d6 t+ C) E+ [ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
# m' h: u0 b7 K) B: Z5 P9 T' Y ; Note: expecting to be run when the active window is Explorer.
& k* K) a. Z9 z; W, F' | ;
; A5 y$ `( c5 T. U0 Z) ` OpenCmdInCurrent()" j$ M$ d0 K M
{
0 ?* M) Q0 F9 p V! g ; This is required to get the full path of the file from the address bar
6 n7 l/ T; ~% P8 b WinGetText, full_path, A6 j# o2 g2 z, M4 u
; Split on newline (`n)+ ^2 ~# s4 A! I) X) C
StringSplit, word_array, full_path, `n
5 S3 V% Y% i! y+ r T ; Take the first element from the array! p) x- F. R8 ~4 P7 O( R/ {
full_path = %word_array1%
' b9 J6 \. f3 @$ `2 W1 D& a1 z; B ; strip to bare address
" J% l! Y% ~ k) o& N" h9 S full_path := RegExReplace(full_path, “地址: “, “”)! b* x& y% T6 i4 {" E) |
; Just in case – remove all carriage returns (`r)* d2 T9 _$ V/ d% k8 U0 Z" H3 ]' g6 Q
StringReplace, full_path, full_path, `r, , all* Y- }6 j3 m6 W- W
IfInString full_path, \8 Z8 O( ?( [! o/ U1 q( t* q' k; n
{6 v) Q8 f7 {! k4 M6 I" I2 D I' z
Run, cmd /K cd /D “%full_path%”
6 w0 j. Q' N/ M; O3 w+ D. a. b }
3 w) D$ |0 B6 D. r, e else
3 J; `# y' @1 O# q$ p {
) Y1 w6 A( }2 i6 z) t% W: {- | Run, cmd /K cd /D “C:\ ”9 u, o' J; I+ H& s5 y1 R
}
1 o! t) R4 ]5 c' C2 \5 t }
# A$ w* t, f; G- Y3 w8 A) ]) z3 j4 c 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& J) J2 I) F& |& Z+ ~* G% p
这段小代码肯能有两个你需要修改的地方) a: K# n" X( E# M% r. L1 {. {4 P
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' m6 s2 x( F7 {3 S& @ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “0 Y* ?7 I7 S8 o: Z {1 P
|