此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 e" Q3 j0 l7 x 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。" ]9 @+ I+ q: [+ W/ g2 F2 ^/ ]
方式一:
& t/ [& r! g) @* i- G7 I7 }0 S 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# q5 D l% J! ?* ]6 t. }9 M
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和$ Q: m- m/ z0 _5 ^: H1 |
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。' d( N% d1 O" B# D
方式二:
% V5 F; e) i; u% _3 z: T, b* E 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) L+ X, G$ c* S0 ~& i' X; w SetTitleMatchMode RegEx. {- Y9 \" r1 V# `0 ?+ Z5 Y+ n
return
: ]: b5 ~6 M- v ; Stuff to do when Windows Explorer is open8 D1 \2 d8 n; O9 F+ b7 i9 Z
;
2 N7 w/ _8 D2 R9 B& m( c3 H #IfWinActive ahk_class ExploreWClass|CabinetWClass
k! |9 h- B F ; open ‘cmd’ in the current directory
! \; N" C+ S. W3 Y$ E ;
9 {! S- g0 K& m: Y2 ^ G' o #c::! g. p0 m: r( E' G5 h5 g
OpenCmdInCurrent()5 a1 m3 [7 O9 w8 d9 w
return7 w/ {0 v% c9 `1 H" y/ k4 _
#IfWinActive$ }, O$ k: g0 d T8 f
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 }' |2 x- [1 z% J3 u8 G0 V8 T% \8 s5 _ ; Note: expecting to be run when the active window is Explorer.$ k7 e. c+ g6 i4 ]
;' Q1 I0 A6 \- ]" z9 [! z
OpenCmdInCurrent()
) j$ P5 [; ` g% Z9 B {3 z* [7 t2 }1 d! T
; This is required to get the full path of the file from the address bar
* T3 @/ O$ T3 J& r" [ WinGetText, full_path, A
& ? i+ E7 i ^+ \+ a& m ; Split on newline (`n): ~, f9 \4 M: T; {+ \
StringSplit, word_array, full_path, `n
( a+ D q( {4 `: J) y, s5 h0 e ; Take the first element from the array
- \( ^/ o2 G8 O$ o full_path = %word_array1%
/ z) j7 K4 l& n" ^% Y ; strip to bare address! k1 ~2 N& N# z3 y( U8 i5 |' Q1 M7 a
full_path := RegExReplace(full_path, “地址: “, “”)- I" d9 m) V7 e
; Just in case – remove all carriage returns (`r)
) x/ S9 g# ~( t) ^5 c StringReplace, full_path, full_path, `r, , all
9 T/ C. ^4 ?( A' V- D% M" j2 E IfInString full_path, \
! f' P$ m0 u& W4 B0 ?0 D) ~: l' E {% D" N' b- I) v+ p3 |0 d5 l: w
Run, cmd /K cd /D “%full_path%”. Q9 m7 @: g# m8 P9 O& k
}
; N/ W/ x4 g' Z" c$ O else
; s4 y% s. d9 y4 m3 ~$ N7 g {
( t/ H. q. t4 n; ]$ H Run, cmd /K cd /D “C:\ ”0 f# d* P2 b' |
}
X( `5 [6 u: v; z, a }1 K/ l/ M* s& O6 d" X* p
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# g) V" w: F9 G4 W 这段小代码肯能有两个你需要修改的地方
# V' ?# q! e2 M! P$ X, b9 p! Z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键+ Q3 \- ?% V% x* s: u
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
# s+ ~; i& u' P4 j |