此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 R' W6 ^( e/ P 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。+ B: K; } `. [9 D( I
方式一:
8 S h, p+ l6 o( }# R 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ g0 P1 S5 j* z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 \2 ?: O7 |9 A" @' k- C
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 U. Q$ t/ U7 f% p3 r! E
方式二:
4 y$ ^3 P; ~5 [ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# ]% ^4 p( s" f( t! B6 k9 E4 ^% R4 _ SetTitleMatchMode RegEx8 U; W) }1 a3 }2 b" f) {, Y
return
* H+ }* e2 W8 `5 T7 P ; Stuff to do when Windows Explorer is open
# Z! F$ a: r. X' k" D ;# y6 M8 ~: M: B4 ~% ]
#IfWinActive ahk_class ExploreWClass|CabinetWClass6 x: g6 o0 j9 p, y) {
; open ‘cmd’ in the current directory' ~: L9 l7 R6 m! h4 S. g
;9 u. M8 J6 {/ H: |1 n) S
#c::
" C' ]& f& h+ ^; k# z8 g OpenCmdInCurrent()1 H" I, w# f% B! p3 @
return
. D6 J7 H1 r4 o- g# U# \ #IfWinActive
1 I0 G$ D! d# [. t& C' r ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 L2 O$ a. w v1 S# k
; Note: expecting to be run when the active window is Explorer.
. n! ~! a* _3 d1 F ;
+ s, t% F% D0 M' m: `2 c OpenCmdInCurrent()
( u6 A5 F0 U! s- Q; I {
# {% h! I& Q- z ; This is required to get the full path of the file from the address bar
) @" i" y. W g) y i+ t. C WinGetText, full_path, A/ w: \: ~1 W, {5 e4 D
; Split on newline (`n)
- }: n1 t$ p1 v. j0 `, L4 q StringSplit, word_array, full_path, `n
1 c7 h- P- R/ `' i/ W ; Take the first element from the array
. ?' k2 ?& E' Q+ V full_path = %word_array1%
! l+ T& a/ H* ~7 e& I$ f ; strip to bare address
* q9 [( |# M- X3 c full_path := RegExReplace(full_path, “地址: “, “”)7 s" Y7 Z w/ @4 ]
; Just in case – remove all carriage returns (`r)
" \, Y/ `- z5 y. Z2 Q5 F- J/ q StringReplace, full_path, full_path, `r, , all
, O1 C9 b& z. q6 [' U+ ?& f; u IfInString full_path, \7 P+ B- K: N, T3 z2 Z5 u
{8 X# g6 ~+ G' c: ^
Run, cmd /K cd /D “%full_path%”
0 x' Q+ V8 }& g }+ ~; V y' s$ W" G8 e8 c% p+ Q
else
8 S0 r+ U- p0 c! g2 H) [6 p {5 j/ k8 ?+ z1 f9 r
Run, cmd /K cd /D “C:\ ”
- i. W ]1 x4 v0 O4 s+ p) d }
6 L6 |* M$ t! r7 o: b }( g1 S( H% c. p
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: _/ g$ i& E3 G, ^ S0 |5 F 这段小代码肯能有两个你需要修改的地方5 f1 b, F9 O4 y9 B, o) J$ V6 c3 ~# ~
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
/ v( D( ? e! |7 S: |; |% L6 P 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 p. l# s% g ]
|