此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ y! P/ {2 |( C. ?4 G0 k) ]
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
6 g" O! M3 p" n0 ~2 s/ s5 S 方式一:
N N5 h. Z1 m* v( e6 T 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 h* y$ c y( ]' I0 f 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" g- k0 {$ U* o2 I/ D HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 i! M$ ?9 A Q+ ]1 u3 m( e% \ 方式二:
, \1 g3 q5 v& W ~) ` 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 P3 H O$ q! I SetTitleMatchMode RegEx" w( V; h/ m. G: V: I v2 @ E- x# Z7 Z6 m
return
5 a( D3 a# M. [% @( o9 W ; Stuff to do when Windows Explorer is open
' W( L) ~# l: J1 u) e. ` ;
8 R* T: B% M6 @3 u$ v1 u1 w3 T #IfWinActive ahk_class ExploreWClass|CabinetWClass
2 G0 v5 c6 L7 w* Y ; open ‘cmd’ in the current directory
3 w( W: Q& u1 O& C% Z ;
. _9 q6 Q% j! g3 ^. ~" i3 n4 O #c::1 S; S f3 E- V7 I# @ Z6 Q, B
OpenCmdInCurrent()( n/ @, N% W% y8 y8 c
return+ X6 j0 Z# C9 Y5 F
#IfWinActive
0 K5 ^0 y5 ^/ z5 l) U ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 Q+ u' U0 A; Y. C) g$ M( }1 L
; Note: expecting to be run when the active window is Explorer.
: [% ]/ P' ^+ Y" ^$ q/ |+ K) t ;
- }' W' i4 i/ T& w. A/ a OpenCmdInCurrent()
, I, @- D& J* I# n0 d {5 r6 E+ |# O. A
; This is required to get the full path of the file from the address bar
5 `4 P/ C5 V, V6 P- d2 t WinGetText, full_path, A+ h( k, m S8 t
; Split on newline (`n)
5 Y: `& @& o( T: N StringSplit, word_array, full_path, `n1 g+ N/ Z. R$ q. q6 ?
; Take the first element from the array0 A f- y1 {2 e
full_path = %word_array1%
0 Q# H3 q- a9 } ; strip to bare address: f" d# u; Y' z9 j) M- M0 M
full_path := RegExReplace(full_path, “地址: “, “”) O; Q9 I p3 J1 ?# a. J" L* f
; Just in case – remove all carriage returns (`r)
" O- P: L; J! O4 [8 }( Z StringReplace, full_path, full_path, `r, , all5 s% {) C' Q) m& A- U9 W
IfInString full_path, \
6 y8 ^( o2 q8 X, U {( M0 V5 O. O& q/ Y8 m; _& U
Run, cmd /K cd /D “%full_path%”
` d2 e7 R8 C( ]( `+ u) w }
. a6 V" n @# o# D else
3 E+ \* Z$ O* Y- T4 x3 z+ C& ` {
. |5 H- d+ O0 B% C Z Run, cmd /K cd /D “C:\ ”# v$ P y; C2 ?: e
}
# i% p6 \" P6 K; h3 n2 Z }8 b# I7 c, ?/ a3 A3 [, k
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! Z5 V* b# g- T$ z& T, S
这段小代码肯能有两个你需要修改的地方5 @" N. T$ z- S V" Y ], a
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键1 M$ X) e! A( K: x
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “0 O; u5 }* X2 T& {: k5 v, q
|