此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
9 E# s$ s0 w& B" J; n# n x6 b 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, Z o, O& ^3 Z; i' w) ~ 方式一:8 \/ L0 Q, m, y' Y1 Z" F' C- S
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,& H* L3 V5 B/ Q7 R
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 E, G* w# }. O1 G! F9 Q y HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ O. y5 z8 Z8 @( _& g# n
方式二:
1 b3 S6 t8 p$ q3 I$ t: S2 p 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: b$ H' |8 k. ^6 R8 W7 I1 i' N
SetTitleMatchMode RegEx
( o: e4 E) _6 ]* t. b# t' b return
8 e$ e5 \' w2 b% i; z ; Stuff to do when Windows Explorer is open
7 z3 }+ u9 w% p$ Q0 i+ S5 P. B ;
& c0 [ ^* _( q4 S2 u( t2 m #IfWinActive ahk_class ExploreWClass|CabinetWClass( U s) [ H" C* R) `9 R
; open ‘cmd’ in the current directory( M* k' A. j$ J+ e/ W
;
+ W& M, e5 o% p- z0 l' b5 M0 G- G #c::8 u9 ?. G+ b. V; q! Z1 w( x9 I
OpenCmdInCurrent()
; c0 e+ C g9 a6 t" H return' [ D4 E/ n2 u8 k0 i h
#IfWinActive
9 H: F: J: d& T4 S' n# \6 n ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 q0 P# e* a, Q8 f4 L ; Note: expecting to be run when the active window is Explorer.
( t1 V3 _) J" k3 n% i5 |; _! U ;
" Q& I: }7 ^) s4 a OpenCmdInCurrent()' M; k3 [2 w2 U9 j
{6 k# C6 s; y( \' D
; This is required to get the full path of the file from the address bar$ T: i; w; a C% a$ o- ?
WinGetText, full_path, A! I- E/ j. D/ J# ^6 n
; Split on newline (`n), B1 x( E, q o% l, a
StringSplit, word_array, full_path, `n6 w) v8 l: t# H/ E% }. t. y% j
; Take the first element from the array
2 n1 n6 U6 z, w. i- D, s! t+ ^ full_path = %word_array1%3 \. E0 [. [' ]& _, Q
; strip to bare address+ n, I( X, G: u) s( ?
full_path := RegExReplace(full_path, “地址: “, “”)( h" }2 L: i, Y# i8 _) h
; Just in case – remove all carriage returns (`r)' R2 p3 G7 {# x" J2 P% D7 q: a
StringReplace, full_path, full_path, `r, , all
9 v& q" J' c, w$ m IfInString full_path, \
4 Z, `7 _" s1 b6 k% q5 f; j% [ {
1 V( A& j& R( w# i$ h' i Run, cmd /K cd /D “%full_path%”8 F$ |: T- }$ v1 N, k
}
8 F7 ~ T% a4 A* ^9 d else3 [1 N4 _. z: p, I
{* V. L o0 f( Q. V
Run, cmd /K cd /D “C:\ ”
! N" T7 `( x: l9 z }
2 f% q2 h. b1 h6 w5 t: u. T3 y4 K$ n }
/ g8 L% U- O; f2 { 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 L8 i5 y# @9 _( R# A7 s) i7 u
这段小代码肯能有两个你需要修改的地方) P2 d, Z; b+ ~5 C6 U
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' c: C h t: H% L
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 R& ?6 E) M' K1 K) u. Y |