此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' I8 k0 Z. u7 E5 i 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
: o) [) ?+ n% @6 j% {. A3 Z; F s 方式一:' Q& u- T; H2 k' N8 r# A
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: D7 k* @$ l7 ^ r5 ^% A 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和0 l) j" e5 A% c0 ~' k
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" ?# I/ u8 M9 O4 \ 方式二:/ m% H8 U2 Q& j, K9 J8 T
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: [' P, e* d7 v" C& v6 Y g
SetTitleMatchMode RegEx
& f3 y& X# ?# d7 R return# }8 ?$ `. u2 [4 K) P* d& o
; Stuff to do when Windows Explorer is open' n( R, O+ }; E
;
; g2 b" x: [1 C) T. A #IfWinActive ahk_class ExploreWClass|CabinetWClass$ [# k" I0 ?5 k: P6 ]) y
; open ‘cmd’ in the current directory
_! U" d% P' w6 ~ ;1 D1 H& C/ C; }) e z- p1 ^# Z
#c::
7 k# I6 I! u: v OpenCmdInCurrent()) }8 f+ j, a2 D( I+ o5 {
return
% e: L" c, _, d$ z #IfWinActive# k! T8 R/ Y: H0 R6 a/ \7 u
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
0 k8 d) d0 W: }" B6 M0 v8 k0 J5 p3 S ; Note: expecting to be run when the active window is Explorer.
. d1 o% l" b1 q5 @+ P ;
+ y1 m+ @2 t* Z" E3 R OpenCmdInCurrent()- \ `8 S0 U% v5 K2 l
{
3 i& x/ M e s4 w# y, e7 k5 s0 ? ; This is required to get the full path of the file from the address bar2 f5 q, k, _( f8 w1 y& C
WinGetText, full_path, A
O4 l8 T0 A1 B+ W ; Split on newline (`n)8 Z5 Q$ @" r* ]% ?" f! b1 t
StringSplit, word_array, full_path, `n' \/ A/ _5 {: o: w5 G( G. y
; Take the first element from the array
, ?# S( |9 Q" Z6 V0 k full_path = %word_array1%
6 Z' S+ }5 y) `. Z ; strip to bare address. M; p v1 ?& s! m0 p
full_path := RegExReplace(full_path, “地址: “, “”)- T" x5 o9 F2 w5 T# c/ P
; Just in case – remove all carriage returns (`r)# n6 b# G8 ^3 j8 M" J
StringReplace, full_path, full_path, `r, , all
6 L9 D) g- k, w IfInString full_path, \
4 ?9 N* V2 g8 ?* e0 ?" \4 N2 e, w {7 s, k M1 }& C( S7 G! k
Run, cmd /K cd /D “%full_path%”# X8 H2 \+ J1 h; x3 c7 E1 c
}1 J" a+ A: H4 ^1 ]) j( y
else N7 i1 M1 g0 v
{
. i' ~+ q& G$ E, @- L Run, cmd /K cd /D “C:\ ”
0 P% s% J5 w+ z; E% j( ^( [6 w& j }
+ n( I* [0 } n6 K" h }
' w5 R/ Q" M( |9 k8 G 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
1 r+ w, ^4 o" Q4 | 这段小代码肯能有两个你需要修改的地方
g* s& l& ]( u5 V 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ U! i* a( c' W7 J3 Z4 f( D
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. n% c( H1 N; a1 y. `! K; L
|