此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。3 I) Q# X8 _5 g+ e6 Q# l' Q, e% b
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
/ j& }1 a4 E0 t+ j: }" N: y0 q 方式一:
+ \1 D) s0 G$ N! t: d2 r 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, y) ?* d) L) F
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' }- D1 R& P& p& b0 D! [6 |
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。' X' T! D6 j3 g5 \
方式二:& i- Y% S/ }, z' f
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ R! `7 f- x2 r0 Y% o0 }1 G9 K& ]4 Q" T SetTitleMatchMode RegEx1 E. H. y, x) t; N5 f9 N
return
( [5 v3 T Z- D6 f# m: W ; Stuff to do when Windows Explorer is open
?" d7 E( L" o ;* ~% j% W4 e% t2 k( j4 Q" S
#IfWinActive ahk_class ExploreWClass|CabinetWClass3 q4 U. }) b* }6 ~/ u M
; open ‘cmd’ in the current directory6 ~( T3 Z; s1 h' P: M
;
3 B% {+ S! q2 a) W( x( \& [ #c::
% D$ Y+ V6 Y7 G! S4 i OpenCmdInCurrent() F6 ~! E; ?9 D. C4 G, q# t. A9 `
return
7 C+ u; e9 |( a #IfWinActive
7 U. Y% v$ @4 S+ H ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 F. x0 B2 [: r& C& U- V, P) d: e
; Note: expecting to be run when the active window is Explorer.
+ U2 W( s) S, `- C ;
. }8 g I" `" o+ N. l* C% \ OpenCmdInCurrent()
{- z& V% R: Y( {: J" Z( F {: c9 X+ N& e9 _" V, u) Z
; This is required to get the full path of the file from the address bar) X V7 x3 r7 W
WinGetText, full_path, A
$ m6 m# o* l* {, p0 o ; Split on newline (`n)7 R# V9 O4 B( O% b6 v
StringSplit, word_array, full_path, `n
& T. z: B ?. e9 B) R% \7 k ; Take the first element from the array! {* R5 a& o8 V" T
full_path = %word_array1%
. C( ` V( r' {& d ; strip to bare address) l4 Q; c9 a# }* `! Q
full_path := RegExReplace(full_path, “地址: “, “”)" w% g! F6 L( }9 `# t! D! m1 f% { D
; Just in case – remove all carriage returns (`r)
% ]$ B) w2 b0 T( f% k StringReplace, full_path, full_path, `r, , all
' \! z+ a. B. P8 C* R, A IfInString full_path, \
6 R) Z E, k# e. h! m {& O0 H9 F+ x6 j* k8 c
Run, cmd /K cd /D “%full_path%”7 r7 u9 |2 c- {2 v3 o. C2 y- X! Z+ Y8 C
}
: T) t. G! u7 o1 g else7 b- o( N: T7 \6 z4 l
{8 J, T0 E0 b# x
Run, cmd /K cd /D “C:\ ”- o3 o) `' r! i4 N) X1 d
}
* z2 A$ ]3 j# s0 j7 V3 L }, B) v- d2 U% T8 r' |3 t4 ~" p
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 b4 y$ m# D7 M7 k$ W
这段小代码肯能有两个你需要修改的地方
2 h1 T/ s/ k4 V4 P! A 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键2 U' L) g7 {9 |: Z4 b& Y
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 z) F' A! V/ J1 Z" Y9 T7 |& k+ m
|