此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
# ? n, J) J" h4 G* [$ s5 N 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。3 P3 n. _7 D+ \
方式一:9 W8 T6 [5 F) q& z1 c5 J# @) S
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 h! Q; x7 d5 ]. N' } 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: N |+ ~" H- F( u$ u# {9 D. h
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
: ]5 ]% U& q; ^2 e' c 方式二:0 V6 B" }) F- \0 H c9 b& T) V
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:; p9 k e: g$ z8 m' i X! U& I. h% L
SetTitleMatchMode RegEx) c' t% c+ ~" |* ]2 L
return
3 N1 {( s e* ] ; Stuff to do when Windows Explorer is open c) s0 h3 j1 `( w
;
. Y8 h' z$ b( s) }$ P' b #IfWinActive ahk_class ExploreWClass|CabinetWClass, _- L! b" c I% M+ E I8 k4 D
; open ‘cmd’ in the current directory$ I4 }: S9 P5 } ^( W
;8 {- _- e+ h# V+ d
#c::9 E' B: x! s' l5 {, Q1 c& o, Z
OpenCmdInCurrent(); u- t9 k! Y p, |
return
* P6 Y& k+ w& f( Q. M/ [ #IfWinActive" x! \9 N) W9 `' X: l! m
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
0 d" O1 }; g0 \; q# P ; Note: expecting to be run when the active window is Explorer.
" ~9 Q* B! F# L8 Q5 U: a0 E ;5 D1 d/ ^% O7 E2 D; K @/ _" G
OpenCmdInCurrent()
/ t8 g! H8 G" q" ]! ^+ n {
: |6 f2 K3 }2 k' b# t ; This is required to get the full path of the file from the address bar
2 h0 p' m& r7 b- e! q3 _ WinGetText, full_path, A; q5 [: {2 M* \% ]- j
; Split on newline (`n)7 {) Y. x+ d2 {
StringSplit, word_array, full_path, `n: \. o- c- {" y3 u
; Take the first element from the array
9 h, E; r( r% W9 T0 o. g" f full_path = %word_array1%$ p) G/ U* G1 {2 l
; strip to bare address1 w/ s, r+ K8 p# p& I
full_path := RegExReplace(full_path, “地址: “, “”)+ r1 r6 ^) _) ~3 f+ a [, @
; Just in case – remove all carriage returns (`r)
! g+ p& O e8 N2 }& a4 |: R StringReplace, full_path, full_path, `r, , all
0 Y1 {- _* r, G" }- r IfInString full_path, \
+ _( e( k& i5 t6 J {
- L1 W/ L1 U/ J+ e! u Run, cmd /K cd /D “%full_path%”. x- r \4 ]& a7 [, b: b7 D
}
1 I. [9 m) c6 {* O+ [ else( g0 H+ S" A4 P% z! a
{
; N( c2 v4 c( b0 u Run, cmd /K cd /D “C:\ ”
0 Z8 |% B2 m; H+ _: t+ }" L1 @0 Y }
% Q( ? k y' U# G. @ }
8 r+ z( U$ c' T% q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( T1 z+ ?) G& h" E! f8 M 这段小代码肯能有两个你需要修改的地方
1 n( {: }8 C/ i% _ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 i& b6 R$ S6 u# B 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “0 `$ ^- I6 t& a# K( G
|