此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' l& L, L3 \2 U* b4 m
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 |$ o: Q% J8 }6 ]( _7 u4 z 方式一:
! w" m1 H$ I( r0 P 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 w+ t+ q: }7 F1 W% _+ A
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: N! a: w6 z' Q: e! V
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 w# F2 e: B- G$ e7 S
方式二:
6 v* k- b! { q9 ] q3 Q0 V 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:' B- Y. I, L' f& o* U' ~
SetTitleMatchMode RegEx
, K, e, _! g1 X* z p return
: z1 n+ c; b; Z- P* ^ ; Stuff to do when Windows Explorer is open- l% a1 A! ?$ v% |; W* _
;, w0 F7 D5 { A% ~6 P9 U5 I- o
#IfWinActive ahk_class ExploreWClass|CabinetWClass
0 i( M, }2 }3 m, u+ { ; open ‘cmd’ in the current directory
1 d- [; r- c4 K" q* e ;
5 j8 C, L- Y" @( h2 X3 O #c::8 R: Q' E R* I4 H; f' {3 g
OpenCmdInCurrent(): W; U8 K( `1 @ ^; c. \
return: z5 y5 D* T1 [
#IfWinActive
+ Y9 R. H; M6 ~( g ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
$ l( ~: |+ {- ^7 S! Y- A" O ; Note: expecting to be run when the active window is Explorer.
( R& B h: j' i! v2 W6 Y% {2 S ;
8 u* ?; a$ t ?" C* w- {- E OpenCmdInCurrent()8 \& ?1 \( j2 S; v* i! c# `. r
{
7 T. }( B2 h- L2 d4 y8 f" \ ; This is required to get the full path of the file from the address bar
6 e, i4 R$ d1 W/ l" W; H WinGetText, full_path, A- ^' L- `1 X, l/ u4 I
; Split on newline (`n)
( d% P m+ S+ |! X StringSplit, word_array, full_path, `n
- V3 n5 f7 X7 Q* s4 X3 o ; Take the first element from the array
$ N. O5 r3 V9 D7 @ H6 t, S# k( K4 F4 l full_path = %word_array1% L6 N x! }* N9 h
; strip to bare address
/ S7 Y4 H6 v& p. T3 R full_path := RegExReplace(full_path, “地址: “, “”)
! w5 H8 R0 v7 v3 K: _/ u. n ; Just in case – remove all carriage returns (`r)
9 K4 O! w6 n4 f) y6 F2 m StringReplace, full_path, full_path, `r, , all
6 ^1 E. z& t( j& k IfInString full_path, \
: B- O# y; R0 f {
0 T* i& q; A3 l4 t/ i! A1 |# q Run, cmd /K cd /D “%full_path%”
; k7 P( U, \; v: H! `* |$ \, C8 u }0 D$ P9 l6 U: h7 |/ K
else( U7 x( W# x3 T7 V+ Z# H8 p
{
! [4 B) \' A) y+ s( \9 T% U/ [* y7 ? Run, cmd /K cd /D “C:\ ”
2 R. D- y7 ]9 h- Y }
1 j* v6 J% [4 v, g3 T' o* {* [ }
' }- O- }3 ^1 s! h$ O$ n 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
/ h% ^4 v4 G N& l1 D0 @- R5 | 这段小代码肯能有两个你需要修改的地方
, m3 g# O7 A- p$ ?; Z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 N. z! t9 u3 E5 p. Z* X
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “& x1 j* i) N; q2 a: ~) E; v0 q
|