此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。- Q- Z4 r: E8 _4 O/ i2 n; s
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。+ w9 I6 K1 J' K9 J- q
方式一:
7 q2 e$ d+ y% Z! ~. N/ w# Z0 L5 w- T 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ j. ]; @% Q; r" r2 `$ K% L3 z1 n. Y
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# E% Z2 I9 x4 [7 {7 u5 f& d
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" g3 K0 z9 h# f" x. y$ O 方式二:
3 b) G' W* @: s 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( ^8 }- l9 J4 c5 y6 w; n8 w
SetTitleMatchMode RegEx" H( E: D' r8 Y5 u9 H
return. ~5 L& R2 g6 F1 m
; Stuff to do when Windows Explorer is open* L, D" {! V+ F5 l+ Q
;
2 o# ]* v) w M6 Z& ?- A# @ #IfWinActive ahk_class ExploreWClass|CabinetWClass3 C- L3 D: t/ |) X- v
; open ‘cmd’ in the current directory
- c2 R R5 b, B) D% V9 p% {& n ;
" ?2 t" B1 |1 e/ h0 s6 i1 R #c::
' J/ [. m& y: C OpenCmdInCurrent()
* W' ]- `( t" ]: l+ S6 t1 q return
- y. s! J& \! X #IfWinActive
, C$ C" W W" U J+ S1 \ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 H0 r( K3 m7 J1 T( c, @ }; G0 V
; Note: expecting to be run when the active window is Explorer.
: U5 B/ d! Z% A* h( G% Z+ w1 |" L# l ;/ u. z) @! B- b5 t4 r, a* J
OpenCmdInCurrent()
' W7 P, j- U* U- h1 K {
& B' `( A4 B. A5 ~% o ; This is required to get the full path of the file from the address bar( f8 d- t4 j( t7 _
WinGetText, full_path, A
h' d/ E" w/ d% U8 p ; Split on newline (`n), Q+ ?7 P& y/ V. B+ J9 T [
StringSplit, word_array, full_path, `n2 f! ]. n3 c8 B% M2 u
; Take the first element from the array
* P/ p# n5 N V2 n5 B# c full_path = %word_array1%
. n) D# g) J) W" U9 ?& N ; strip to bare address% @8 a) b- X/ p2 b5 A) [
full_path := RegExReplace(full_path, “地址: “, “”)
& `. `4 z$ }7 f$ {7 h ; Just in case – remove all carriage returns (`r): O6 p. m% ~0 _2 W3 c5 [; c
StringReplace, full_path, full_path, `r, , all P9 _( ]7 Z: q3 N1 m
IfInString full_path, \
4 }# }3 j( p1 h) ] {' u2 N5 Q" y% y
Run, cmd /K cd /D “%full_path%” j1 w! B5 A- F$ E" B% s/ g; e& {% D
}7 c: |' i! b* d3 T3 t
else
' Y u. N# ]; [3 O5 }/ X5 L8 J {
8 x7 `' f6 a0 |; t8 J# {; n Run, cmd /K cd /D “C:\ ”. T6 k" y$ y) S7 A4 Y e* \
}% F' [" Y' ]! ^
}
2 b( @! D' g1 F7 ]4 t" m 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 z; ~0 {2 Y; M0 i: q: c) Z# _$ G
这段小代码肯能有两个你需要修改的地方
& x( ]& H- @ M" Q8 e* O 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 K# F6 x; ?0 [6 `, g: }9 j# h 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 e! U7 h# Q$ I
|