此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) w+ J- |+ Z; n4 ^' `2 D
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。- x" R9 u0 g9 b; J d: D3 y8 R
方式一:" F, Y. L; Z; X$ t
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 Z$ A: g% g3 Z$ w
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 J" z" Z. k ]6 V/ F- o# B" i: m HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ K) N% v/ v: o: J
方式二: B, U$ ~6 h3 \% n4 e
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& @( ^: l1 |, U& t4 D& D# d SetTitleMatchMode RegEx
% z! @$ s8 ]; W/ D5 q return
\- x% s* Y% D8 Z( A ; Stuff to do when Windows Explorer is open- i" I5 M% P5 D0 e
;
9 e2 e& B' [* F! Z H0 p* J #IfWinActive ahk_class ExploreWClass|CabinetWClass
) X ~3 Q) f4 l3 k% |/ H5 i/ q" p ; open ‘cmd’ in the current directory2 ]" K) G k7 V2 ]8 H4 B5 S
;) A/ i% c" U5 W
#c::* ~. L. P3 _$ D! p2 u8 c( f
OpenCmdInCurrent()
; j! H3 V: g6 b return( J1 ]5 s3 G% e W: _. J
#IfWinActive
( G# S5 e b- s7 @' u9 o, r2 f ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' _/ N6 m1 U8 s
; Note: expecting to be run when the active window is Explorer.- v d) M6 R5 `" ^! `
;. [- d+ n) H: s- o1 C
OpenCmdInCurrent()
" \7 F# X( U0 u8 w# R# a' h3 t& U {
! h3 a9 [" |7 n5 D1 H, t! a! Y ; This is required to get the full path of the file from the address bar% Y0 o% p5 I& c5 W( {5 x
WinGetText, full_path, A
. I3 B/ d9 \" X* ~+ a# {3 p ; Split on newline (`n)/ V( x: {9 J) `- e
StringSplit, word_array, full_path, `n2 r# Z1 @" T+ S6 l
; Take the first element from the array( G$ r: T0 h. s# c
full_path = %word_array1%# q- t% T( H0 B/ j W+ h# B" t
; strip to bare address
! u/ } r; z ~4 ^) t1 w full_path := RegExReplace(full_path, “地址: “, “”)3 E) y: Q% Q9 y, v( {8 y; J2 B
; Just in case – remove all carriage returns (`r) C _8 H+ n: R
StringReplace, full_path, full_path, `r, , all
& f" V- J/ w3 ~1 {5 N# k; ^ IfInString full_path, \
0 b3 G$ [0 I: B1 n& K D {
C" K4 ?7 W3 B8 H& o9 m' m' b# v Run, cmd /K cd /D “%full_path%”* D% x C' t' N! X& G. j8 F8 f
}
1 v6 d8 c) c/ F4 q5 a" ^) b7 ` Z9 j* f else# @" m" a3 G) C7 B
{2 ?8 u- v' L* I7 p6 p2 H
Run, cmd /K cd /D “C:\ ”2 ^: d5 @7 u6 w0 g4 Z- v! g
}
8 [/ q% J4 W/ } }
5 G: x( F/ h# t 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
' W& a% j( ^' m I- ]9 |& R 这段小代码肯能有两个你需要修改的地方) I. O$ @6 C- ^2 ~4 ] E( I# ~: C, L+ j
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键" y y+ Q5 I. `8 ]
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 [2 c$ g0 f* U- s# o& z |