此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
: s2 ~8 G3 g, F 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 @( u; A0 u# E: |2 I 方式一:
8 _2 c1 c3 j1 n$ {1 ?- A$ f7 t! c 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,& A. l$ i. O$ h2 }. C; h4 |$ b
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 ?# V2 Z) F& e5 j+ S& q
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。3 S! s5 I/ l: C4 W- \( h J" j
方式二:
& D1 T9 y% X7 N 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- T' L- ?" C1 d* V) m* l; _ SetTitleMatchMode RegEx
( s( t t) X: |# M" t$ } return% j. t0 w0 I. }
; Stuff to do when Windows Explorer is open
6 A( o( l' u# p( { ;
2 ]4 Y8 n. O, h/ P9 K #IfWinActive ahk_class ExploreWClass|CabinetWClass
5 j& N" D' N" S ; open ‘cmd’ in the current directory
. e4 D9 L0 @$ }5 W9 o5 B! ]2 U ;+ k) ]1 r, G9 T
#c::" d- o6 w1 u4 H6 O
OpenCmdInCurrent()
. d) M3 W) [7 q' K% _% _6 E( y return
. U3 Q+ x e/ `0 f #IfWinActive
: F! P3 W* i# J d% E3 y. z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
8 w$ f8 K7 y3 } ; Note: expecting to be run when the active window is Explorer.
/ |% M; T8 i6 T! m; ` ;# w3 Y( x# Z Z( W2 _
OpenCmdInCurrent()$ a2 x4 S3 ~9 C
{" I1 c$ C+ c- z c
; This is required to get the full path of the file from the address bar
, @2 f, N# j- e/ v( I; r3 m2 Z WinGetText, full_path, A3 w/ f1 @+ ~# p
; Split on newline (`n)0 L. X% e7 g2 u, u$ ~$ Y
StringSplit, word_array, full_path, `n
- r. j7 C( P7 W ; Take the first element from the array
! G- I" W' T, @; x# N" t! r full_path = %word_array1%
2 |# W: d$ P, {, \( \ ; strip to bare address
# R7 `& ] s( G% l$ [! @ full_path := RegExReplace(full_path, “地址: “, “”); b9 A) p, ~/ a, A& A; X
; Just in case – remove all carriage returns (`r); F7 E: `9 L/ o A
StringReplace, full_path, full_path, `r, , all
" U; s8 X0 g$ a; o9 _ IfInString full_path, \' w4 P3 B) m, Y6 p$ p5 _% P/ q
{
% D. G# Q# Y7 o* A( ` Run, cmd /K cd /D “%full_path%”
! S0 T7 X9 Z: z: z7 O0 V* X9 t0 ` }
% A3 q4 j% d$ P else- O% a( S# s# {" h: @# M- p
{
5 G% C# }% W6 u; W$ \9 r Run, cmd /K cd /D “C:\ ”) L( D, N& R* {' _$ X% D$ S
}8 p* \% I1 ^1 L3 Y4 D" b2 h# O0 Y: Z
}
' q' i, k; K6 T 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! d, h0 T/ N* L' ~9 C$ l5 F! d' ~
这段小代码肯能有两个你需要修改的地方$ O. f( R/ i: S# }1 M: P
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 G7 l: A- A/ l) s5 z; E) a 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 i, l+ {6 y+ P2 T3 m
|