此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 }# L$ G' H6 _! [! g1 L$ P9 d
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 O5 _6 Q# A0 r* t* ~$ e7 q3 J 方式一:
0 O. Q' T5 B( \0 n* k 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,) u- U5 S8 \8 k8 a
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' ~6 Y" Q0 O/ s
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- C5 Q# m: D% U" b5 y# |1 d
方式二:
% d: g1 b2 o2 z: _# O. k 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( f4 s+ `8 t0 J, Y5 u5 m SetTitleMatchMode RegEx4 A I, y2 I$ o8 Y$ B: c8 W
return
5 L s# A) I! Z$ E! m2 T ; Stuff to do when Windows Explorer is open
/ E6 V3 E* Z. ~) c7 | ;
* l2 J( H8 J/ z! \; j #IfWinActive ahk_class ExploreWClass|CabinetWClass; O+ g! k( U: n9 H+ v4 D
; open ‘cmd’ in the current directory4 c6 `' [0 U0 t$ i" ~8 T6 K
;1 P. ?* O6 x. H, n+ P
#c::% z) e. O! Q9 S1 [. q, |
OpenCmdInCurrent()
% P3 \+ Q6 _. f9 D1 {/ Y& W return+ T5 f' e/ y1 y' \$ i- V$ G( Z
#IfWinActive( F0 H, p; e9 g" h% ~* u8 u3 C
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.. y) O. v8 @% ?; b5 {. C6 V. X
; Note: expecting to be run when the active window is Explorer.2 j$ |; ?0 S6 p/ S* S7 n
;
2 J: M% q$ r7 K OpenCmdInCurrent()
, p7 e! s3 ^$ |4 U7 Q {; ~7 A! j/ @" @9 g: P$ a
; This is required to get the full path of the file from the address bar/ S( y) q! X2 T9 L' p+ m0 G
WinGetText, full_path, A" b1 w+ D0 P8 Y* B+ w3 b# B4 J
; Split on newline (`n)
, R& V7 y4 N- Q) i; o StringSplit, word_array, full_path, `n% _8 }: `& m, y9 K* y+ X. u
; Take the first element from the array4 c3 e! { p( M) s$ S# w
full_path = %word_array1%% j1 v3 Z# A# N
; strip to bare address
t; c; _% _9 ^0 m# I( M full_path := RegExReplace(full_path, “地址: “, “”)
. q7 p/ q" \5 G8 [4 ~, n/ p ; Just in case – remove all carriage returns (`r)
- Z& |+ a$ r: D4 O$ g, w StringReplace, full_path, full_path, `r, , all: v5 b1 L; R- |
IfInString full_path, \: O# r1 {0 x! A d! J3 e/ o! F
{
' N7 B8 ^7 u* Z* E9 I5 B7 b Run, cmd /K cd /D “%full_path%”
7 k E7 q P" f* G }4 e% K% R Q# d) |2 h3 _- \: g
else2 k! Y( v% A2 N' V' H0 a
{
# ~5 a+ J6 F. g2 B# b. y Run, cmd /K cd /D “C:\ ”
$ u* F3 r9 O+ ^; f; P% J. ]: v }5 Z x6 |3 V5 {) p( O# \
}+ O: U! m8 Q a% T; h; j
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 E- R3 |* S/ _) ^* I2 C 这段小代码肯能有两个你需要修改的地方
+ ^* T! ^5 M; t8 g: m 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% ], Y0 t6 j: q$ m# F/ X: K" x5 F
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ `. A: H, U4 V/ o |