此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ t) Z1 |" E& U6 i" n- ]
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 {2 X \* @! o( \2 g
方式一:
# Z4 u/ {: T7 V$ K/ Q$ F/ ?' W6 W 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ i7 a$ f* _8 |$ ] G
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和( r& j1 M2 z6 P! e- N7 A
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。7 M" d4 |4 Q7 r |9 J7 i
方式二:4 b. V, p. a' o- ]6 Z/ j9 k
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 U. ^6 q. v4 w/ ]8 @ SetTitleMatchMode RegEx
$ a' L- @( R4 \8 z. M/ L) l( H return
( v, c8 p& O5 s; N6 a. b3 [ ; Stuff to do when Windows Explorer is open/ o! U7 ]3 I8 S6 X' `2 y
;
8 d# _' d3 L, {" u0 F2 P7 ~. ~ #IfWinActive ahk_class ExploreWClass|CabinetWClass- F. W2 H, b# P! r K! M
; open ‘cmd’ in the current directory; U# I# n1 H# g
;
% h( Y8 j0 B9 M, S1 e6 h T" _ #c::# E: G) O0 r5 |- J7 [; m
OpenCmdInCurrent()2 z9 O9 l0 |0 a/ G+ Z' I
return
# v: Z! [& O2 J8 ^9 k% @8 F #IfWinActive
: _& I- K$ q3 J. W' y: _$ H ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: G2 v% c( @1 W/ p" J ; Note: expecting to be run when the active window is Explorer.( \; r5 e) H' {9 T! B
;
9 T8 _5 {7 ~: H! h( ~0 h) z OpenCmdInCurrent()
' Q$ {- g4 C: X. V ~: C {# Q0 Y% d: }0 @! z- @/ }
; This is required to get the full path of the file from the address bar( b$ e/ O5 \) y) q6 C: |" i, A
WinGetText, full_path, A
% r/ U- Q* |0 E5 @. e4 q; t7 o+ ?* h ; Split on newline (`n)
, R% G) F: H J- m z' n- t: [ C StringSplit, word_array, full_path, `n5 x, w4 B! i5 m" z! f
; Take the first element from the array0 f7 F( Q/ ?# l: P3 ~2 ~
full_path = %word_array1%( ~: H9 g, P% g. m
; strip to bare address
4 b; V* k$ f5 q/ s, u) v% W7 C2 o full_path := RegExReplace(full_path, “地址: “, “”)4 y- I. T; U: a# k# D# T
; Just in case – remove all carriage returns (`r)( \+ D0 G! z m! G' h
StringReplace, full_path, full_path, `r, , all
3 H: K X2 u1 } K4 @1 G IfInString full_path, \, W: C! E6 b% `% u- s
{% \: U4 y7 k; I1 L5 b8 T u# z3 s
Run, cmd /K cd /D “%full_path%”
! M6 [+ Z s1 I5 `. X }
) f7 T( A: C2 u1 V: I2 Y. } else+ j+ |8 I5 q2 V: {
{6 W0 Z" k& a n" b
Run, cmd /K cd /D “C:\ ”
# N2 Z+ d+ x( u' [ }
; e% k) I: m9 g; M( V0 R }
# q: N# ?& P6 q7 p4 n. ` 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- g: m. p9 l) R0 b7 O' c5 p 这段小代码肯能有两个你需要修改的地方: s& |+ s3 q: T
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键2 }! I* e7 k3 X# c
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# z5 S# l M" o4 F5 u$ s& i* }
|