此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 v8 L2 C* G% l3 s* h( K
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 B1 z2 k/ P: v. ]
方式一:
3 |* p( f- A8 {6 P1 c 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ }; B6 D* w2 V- Y) i
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和( s6 n& b* w+ \: A$ J! O+ ]
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
( e8 _! X2 \7 k8 T 方式二:) ?$ F" k2 R5 {1 Y1 _/ g8 M& y$ {" A
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& U/ W% V) M+ ~6 @; } SetTitleMatchMode RegEx0 L* h" _' h3 T) Z0 Z, b1 c3 W
return
5 b" a! I2 l7 J# l: y9 S+ J ; Stuff to do when Windows Explorer is open
: Q5 ^6 M; b$ L+ G5 L ;$ x. a o4 ]* q( b) \$ @
#IfWinActive ahk_class ExploreWClass|CabinetWClass
! Q8 A: M2 B5 T4 t+ } H+ K ; open ‘cmd’ in the current directory
- e0 X1 c; V$ x ;
" _* i& v$ Q$ g# N/ H #c::- b7 h f0 ?( O! A8 V- w
OpenCmdInCurrent()6 |+ T4 P7 \) o i
return
; A$ I5 t& s; _0 d# P #IfWinActive
0 q2 ? u. y* K) d. w2 R, ] ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 B4 N/ U7 w- z5 c ; Note: expecting to be run when the active window is Explorer.
0 n0 O/ B1 z! r3 ~1 X2 u ;% }, B3 v; W) G Z
OpenCmdInCurrent()6 n4 E& m, q' k! P
{
' F0 w' `/ o2 ^8 t% @, J ; This is required to get the full path of the file from the address bar
& O4 V% e6 a$ [6 _) q( a. L WinGetText, full_path, A) @; O+ g1 n7 h
; Split on newline (`n)6 i+ w$ Q$ ]: P0 @5 |8 p6 `
StringSplit, word_array, full_path, `n M" O7 T2 H* o& A
; Take the first element from the array( }3 M: ?# w7 [+ W4 {% g% U
full_path = %word_array1%
8 A( @% i; f8 d: o ; strip to bare address
* d8 B9 _$ M/ C- R full_path := RegExReplace(full_path, “地址: “, “”)
- h" g1 J. l. j; u4 o( V6 A ; Just in case – remove all carriage returns (`r)
4 x5 v: E3 {$ ^* m+ `, R StringReplace, full_path, full_path, `r, , all8 k5 ~- M# B( o! L
IfInString full_path, \$ H/ k9 P: I6 z2 j( H/ d
{ @! ]3 e' P3 G0 K" \( b% k
Run, cmd /K cd /D “%full_path%”
% m* k! {5 e! r$ P( [( z3 d }2 |& S& {- x+ o; G6 J. i& ?9 x1 \
else5 R8 o; Q" v9 n/ |: h; p& x
{- s4 y# Z6 l7 G* p- E
Run, cmd /K cd /D “C:\ ”
0 b* Q0 e1 b8 v% c }
8 f$ ?% T! b% E2 ~ }
3 B# q A2 A g# }9 x! w 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* w: A+ O; w+ W6 i" U 这段小代码肯能有两个你需要修改的地方
7 p6 D0 X$ V3 Y7 o$ ?6 Y 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 {3 U4 ?# w# Z* L9 ^
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
- |0 r z' u* \: A! M2 ~) U; x% D |