此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ b7 Y6 Y8 J" c% m: s; r
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。0 w0 B2 L E8 u- S
方式一:! I/ L) G6 i3 L! ?" ~$ t
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,; S" g3 R, _) W5 P3 @' |) ?
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! p. {: L4 T9 j- w. v' W2 W4 {' Z0 J
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& \ G+ _" P" V 方式二:
! [4 @) V# w: _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:+ A( p& \2 Q4 {9 c1 g, U8 q
SetTitleMatchMode RegEx8 A% {+ e. Y9 @
return
: d, A3 O7 G3 N* r: }$ U7 y5 u ; Stuff to do when Windows Explorer is open- w7 r* o! _; H- `
;
( k3 R! d8 ?6 I4 V/ t( N: b #IfWinActive ahk_class ExploreWClass|CabinetWClass
$ k$ @9 \9 a/ f ; open ‘cmd’ in the current directory
$ q" N! k' \5 U8 y7 b% p ;6 n# e. ?# Y3 U# M- w# d; _7 \
#c::7 r8 P1 @# G2 [6 |! l+ S5 t6 X" ]
OpenCmdInCurrent()) ?1 n/ S/ M+ }, c
return. R' o0 o1 O+ N3 K8 F7 p
#IfWinActive4 ~- M R- s* \
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% l, [1 S2 `' H f) j$ v ; Note: expecting to be run when the active window is Explorer., f& d6 y f) b% T2 d" k3 p
;: e. a8 _$ {3 K0 S! T% P
OpenCmdInCurrent()7 q2 n4 k) ~6 i/ T! N$ s/ o; K
{' u, A6 u' c6 L, O
; This is required to get the full path of the file from the address bar& F4 i P( `4 N$ [$ q9 Q* p* ?
WinGetText, full_path, A: f$ [6 t# Z: E+ W
; Split on newline (`n)
3 r- A1 K* o y& k8 k6 F. r, F4 b StringSplit, word_array, full_path, `n
- Y1 J( g$ m. `7 j ; Take the first element from the array
" G& c X5 s% p full_path = %word_array1%4 B0 ]7 k5 }- V3 H3 R5 H
; strip to bare address; h1 X- K- `6 A+ K
full_path := RegExReplace(full_path, “地址: “, “”)
& u( c) e8 \3 O: g- v0 Z" F& ? ; Just in case – remove all carriage returns (`r)5 g+ Y9 F1 y2 ]+ y; p. U! } d
StringReplace, full_path, full_path, `r, , all
. t" h* S0 H$ p$ ]$ c" Z IfInString full_path, \
" _' I# f4 b; V8 m/ I! U/ L% i {
* Z+ o& C! Z+ E2 P# L3 P+ z Run, cmd /K cd /D “%full_path%”
" ~: L* M6 q- a, @. f3 l: N }
4 o4 e7 h) a- s: n( V else B6 g: c8 w6 O. c8 c, O
{
0 Z0 U- P6 _* p; U6 V$ I+ ?; O, B6 A1 } Run, cmd /K cd /D “C:\ ”
# s+ h+ z: V6 q0 ^8 u9 m }
& c2 I/ M Y# }9 I. C' K+ B }
5 d6 l/ T4 R+ h [' ~ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 R0 `4 j* C. E5 D: i 这段小代码肯能有两个你需要修改的地方
- p5 }0 m! r$ V) Y8 u 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键: j/ w0 ] i, y/ p- }: R
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. |/ b! N! Q4 }+ H e/ ?- r |