此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' m% Q! T$ N- y7 i% Q; `, a; r
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ v/ ]: q1 c2 \1 ]: b 方式一:, d+ d8 u+ ~# q$ b- L# X2 b
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,& t% b) o- V% Z/ O
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和. V, q* w- r' r. S0 w. Z- N
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ l& ]5 e' W, `1 L% U4 `: D
方式二:
/ { F4 t$ y \& k* f 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:8 P5 k4 a; ^0 s: l% e
SetTitleMatchMode RegEx
. i8 X- ^% O0 V4 _# e' r6 `. @ return3 p# V# w* m4 u% o
; Stuff to do when Windows Explorer is open: @* M/ x: c0 G, G: p4 _
;
1 ], Q# o) q! Z' e1 U #IfWinActive ahk_class ExploreWClass|CabinetWClass( @/ b5 V; X% {9 f! `$ |: ?, @
; open ‘cmd’ in the current directory
+ v7 ~: B( @; [/ b ;4 p' |* Y1 D2 A/ G$ i y
#c::; N1 ^; z' |8 p! @
OpenCmdInCurrent()
0 q e1 O+ ]( i, `! P' r return4 }* A5 N; F- R0 [. X
#IfWinActive
2 r, r) u* w e/ Y ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 O$ s% G/ l9 p
; Note: expecting to be run when the active window is Explorer.
' ^: f7 R0 k5 }# C ;
5 B- K. \) ^8 }, O OpenCmdInCurrent()2 ~; X1 D7 s4 y% t) P4 T
{; l9 Y/ ^3 R/ O6 B
; This is required to get the full path of the file from the address bar
& Q8 d1 ?- X- {8 G% u$ D1 p WinGetText, full_path, A7 @7 S$ \# P4 [5 T3 m
; Split on newline (`n)6 v* ]% W' i0 |
StringSplit, word_array, full_path, `n/ Z1 E5 }6 N' g- Y6 u* \5 l
; Take the first element from the array# Q( U; \1 h+ D1 B# N3 w
full_path = %word_array1%% U+ u6 Y, M* E/ G+ c: @: R
; strip to bare address
5 Q6 ^* v% q0 ` full_path := RegExReplace(full_path, “地址: “, “”). f- C5 R0 _1 ?' e1 F+ C
; Just in case – remove all carriage returns (`r)
- s( C8 G5 R, Z0 p3 ^ j5 z7 d3 n StringReplace, full_path, full_path, `r, , all
$ u5 C( e5 X4 B* ~5 f ]' A. s2 P IfInString full_path, \# d) U9 @6 ~ d& C) V8 F; d& t
{" [2 R' F1 [) Z! g+ T/ o
Run, cmd /K cd /D “%full_path%”
2 n4 J1 P) M* b/ s) ?- B3 q }
2 b4 n, A! }& w: B- _- I" | else
/ u R: y' ?$ c( ~ { a$ ]: ^( h& y( A" C8 E* o B0 O
Run, cmd /K cd /D “C:\ ”
) R6 u- _/ K1 s3 ` }( h9 v* q/ O0 j2 ]
}. _8 {9 @5 r) L0 T- K2 S+ t" {: u
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. ~6 J# D6 s) \ 这段小代码肯能有两个你需要修改的地方
- _1 I6 b, H' e 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键2 E, }/ z& N4 ]' y3 B
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “) @/ J3 q2 i& F5 v" a# Z
|