此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: V) i- j/ ~# o3 O5 @' p. w
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% h* _9 o8 ]8 e
方式一:
- c3 ~" j- ~7 m 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ I- W! X6 F8 S; v
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 ]! M* `3 y! Z/ O( B1 g HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。# }% n# P1 ?1 |0 [
方式二:
9 J" @3 a( x0 D( p+ ? 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ M5 `9 _: i$ `4 _ SetTitleMatchMode RegEx
9 s- \- C' E# j" R* w! ] return$ c& p$ y9 Q+ h
; Stuff to do when Windows Explorer is open
# g9 Y( ~. y' I" j* W ;" s1 V R3 j) ^& Y/ `2 ^' O0 E
#IfWinActive ahk_class ExploreWClass|CabinetWClass
( K" H9 f* ~+ @8 B* i7 M ; open ‘cmd’ in the current directory
0 E5 X2 D1 t. M# }$ z# h. R ;0 ^; F! f D9 ]' M' B
#c::
, `, o6 M+ F4 b* n# O OpenCmdInCurrent()
9 w/ \4 C, t u9 \/ j' G& c return
! S2 r% {% K) b$ i4 S0 b+ H1 @ #IfWinActive
+ H: ?4 ?1 u1 S9 q" N C, r- u. a ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* C3 q# h2 `2 Y. W0 w. O* ?1 O ; Note: expecting to be run when the active window is Explorer.
\/ J+ `/ k. w/ z ]" a! u4 G ; L4 N! {: u: z
OpenCmdInCurrent()
$ m1 R g) ?" J( j; n$ d {
4 g. ], s; ]3 |& m' O ; This is required to get the full path of the file from the address bar
- s; T4 y- j+ p& n1 E) E WinGetText, full_path, A( |: K# M; w7 Y* K; ?, K
; Split on newline (`n)
) ^, h1 }3 C* N$ A- Y" r7 x StringSplit, word_array, full_path, `n0 |$ H R, B5 }( H4 Z y2 J R' [
; Take the first element from the array
& c( a& ]' E c2 _ full_path = %word_array1%- `, @( u3 I# K# ]
; strip to bare address
" H7 B1 e0 b% D" h, o full_path := RegExReplace(full_path, “地址: “, “”)9 c( I, D$ e6 E4 `/ O2 U( ^' p
; Just in case – remove all carriage returns (`r)% ]; I6 d# v4 |5 B
StringReplace, full_path, full_path, `r, , all
. k6 F- ~2 V2 f: @1 Z IfInString full_path, \
/ [( @ e7 Y& A G# P {$ l2 O2 W9 y1 b3 j S
Run, cmd /K cd /D “%full_path%”
5 V% r) H B& b' ` }
9 }" C, `( |& b8 p' W+ N else
) @+ p+ g8 a- u2 O$ t% c( k) F {
0 T& O- T: O+ A# z0 N Run, cmd /K cd /D “C:\ ”
7 V- t8 T/ u5 d( E; F5 Y- ] }
2 k. x! S! y4 t9 } }3 }* S7 e0 N+ ^% ]) r
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
6 B! c; b% ]2 \6 J+ Q 这段小代码肯能有两个你需要修改的地方# s& @9 R' m0 ]6 `6 c' t# N! X4 V! Z
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' g5 ~. n" k2 Y: \
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) }3 x* V2 _9 D8 W* T) ~ |