此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 o" ~( ~( @' v( I \5 I$ e
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* o6 [2 d7 {/ A9 } 方式一:
1 F5 V% M# ]+ p! } 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% V7 W( |6 K' O0 o/ k; A 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 p: i" U( N) c8 G' _' h
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 n) T1 b! Z4 f' u4 g 方式二:
1 H( p' B; r* K8 W) n 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
: x6 _+ Q* Y! z5 i4 ? SetTitleMatchMode RegEx
; `: F5 I+ j% c1 l1 V' U! l return, h4 p/ ?9 E! Q* y" A
; Stuff to do when Windows Explorer is open9 s. F' B/ b. I5 [
;# D1 G/ {( T; ~" t& }
#IfWinActive ahk_class ExploreWClass|CabinetWClass
f8 [% I. \9 z! C ; open ‘cmd’ in the current directory/ v P5 f& z: R
;( G- a; v9 _; ]) t5 W( t
#c::
7 C5 O. v9 w5 }/ |" O- v) Q+ ^) s. A OpenCmdInCurrent()5 ^: r$ S2 V0 E3 k, b7 U
return' e! @3 W4 {. \8 y8 R: n: W
#IfWinActive# C @, d. i) M& Q0 i
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 s! Y8 U$ U, K: ~5 I ; Note: expecting to be run when the active window is Explorer.) Z6 S$ H0 u5 d' Q! M6 u; M3 o
;
; n$ }! O- O- d- J! ` OpenCmdInCurrent()
0 E1 E( E+ A7 w2 w {; {! h' Y, K" O/ f5 x
; This is required to get the full path of the file from the address bar
" h# @/ N9 M/ H# u1 t, [2 t WinGetText, full_path, A# V/ c7 p. ~1 z0 Z) W/ g: A- X4 }) B
; Split on newline (`n)9 |, X4 R! h" q/ R& w
StringSplit, word_array, full_path, `n
$ \* Q# x; |( @ ; Take the first element from the array# _" a" Z- p% p/ g/ H$ B
full_path = %word_array1%# y" f; L+ C) h& Z: w
; strip to bare address
- M' W3 j( r# p5 o4 @7 b* ` full_path := RegExReplace(full_path, “地址: “, “”)' G f; S3 b, g* |! v
; Just in case – remove all carriage returns (`r)1 z4 ]3 K. @" H/ r3 O0 r5 u! w
StringReplace, full_path, full_path, `r, , all# Z7 Y) s+ Z7 O g
IfInString full_path, \
# e( k5 e- Q- [+ F# l {
, \3 s) M6 G' V3 i/ D3 P9 w* [ Run, cmd /K cd /D “%full_path%”
0 q- H* K8 L Y3 {" ]! F) c }. l6 l: f1 E. I- D
else
! r& c D Y! r: [& n5 } {
; a; E U3 A7 `$ U# C( r Run, cmd /K cd /D “C:\ ”
1 t4 z9 a% e& M' _ }- ]% {% w5 s7 T( l$ Q
}
& ]' N* k- _! C4 S% {: }2 @ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! U2 [' ^$ s/ U0 i3 p7 O+ G" r 这段小代码肯能有两个你需要修改的地方
p) S# s- A/ E3 v 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' L: a, c7 b/ y1 \5 ?
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
' s8 r6 h& W( O4 Q! c9 }4 Z; ` |