此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ I' {, m7 K2 a% N, g5 C- e9 h; |9 f 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, v; v: u2 a# Q' K H 方式一:+ g; z/ f2 }. x$ ~$ G
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 r* C" {6 w3 J# p
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) Z' n2 T) F0 Q0 a" H" \ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ ?' J/ |, U6 ^' f 方式二:" ? g) _9 G4 Q. s/ B
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- \% x1 X4 u9 z. o8 C SetTitleMatchMode RegEx9 G, n" G0 K! I: E7 @" b
return7 t" @# w+ e& _
; Stuff to do when Windows Explorer is open/ s% p1 l( v0 G$ K
;. v1 y1 q' @( d) o; R
#IfWinActive ahk_class ExploreWClass|CabinetWClass2 D% I' @/ a& i& S8 a1 C/ K) }+ b1 Q5 n
; open ‘cmd’ in the current directory
& {4 z; H1 }6 Z ;
# D% H! ]$ c. K3 i& ~; w$ u3 ^9 | #c::
5 p0 B2 O6 m8 J0 M7 g OpenCmdInCurrent()4 }1 L, J- h' a5 [' G
return8 c6 w0 q# T; i* h7 H5 c5 h
#IfWinActive
) L: y; c3 |) E- p+ w" `9 M ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 V) Y' G9 N R) X& C) U, e, x7 P1 f ; Note: expecting to be run when the active window is Explorer.( a m8 o- m3 e) k, j
;
9 R( }. E- L. j OpenCmdInCurrent()
6 d m6 n3 W9 G7 g5 ?% y& u9 H2 X {
/ H: e2 n1 l; M% u ; This is required to get the full path of the file from the address bar
8 J; N3 Y `; i- E& b7 \ WinGetText, full_path, A' v7 R! [5 j8 l0 w3 K2 o# D( z
; Split on newline (`n)
- h# ?1 I4 e* a$ \) e5 p StringSplit, word_array, full_path, `n
3 Y4 D A" f+ v ; Take the first element from the array5 Z- y$ \" m3 h) E: Z& r3 u1 a) N) Y
full_path = %word_array1%/ c4 R) x2 D/ D, c3 U( c# o
; strip to bare address
9 s; V# I) G2 m- X: [! E" R full_path := RegExReplace(full_path, “地址: “, “”) Y* P3 m, ]: R% T
; Just in case – remove all carriage returns (`r)
$ z# W# B \; H9 U StringReplace, full_path, full_path, `r, , all
0 I8 j" C# q5 F- o8 O; e IfInString full_path, \
9 ]9 h$ U8 S, l3 N) v {" K/ Q0 t& Z4 Y( H3 a% v8 J5 j
Run, cmd /K cd /D “%full_path%”
! Q& ~1 k% M# j1 {/ Y }
! t2 L- }% l, B* l% V else% w6 h+ L1 Z- m: {' D. v
{) e: H4 x0 C( ?
Run, cmd /K cd /D “C:\ ”0 K8 c! H* c2 j; X4 ~! ~( z8 R
}
* n1 f0 ?% D2 U+ m) x" F, X }* C4 X2 k" g* u9 W" `4 c
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。8 }8 \' [' B" W4 p9 o
这段小代码肯能有两个你需要修改的地方) K/ N" v- N6 l5 ^5 d+ T
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# `" T- N. v7 Q C
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; L$ M9 L' H6 o- a! F) l |