此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 j: n/ v& i" X( i; t 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 C9 v, B8 \' p* L
方式一:! C3 Y) I0 P+ o% {8 Y( J: N
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ `7 h: h0 D9 X! n
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 [" s" q8 W* b! a9 Z& }
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。& _- e9 o2 m q. t) |1 p$ V
方式二:
7 u5 m9 G. G1 r+ ?8 t1 d+ y, B 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ H/ X/ \2 z1 g) t SetTitleMatchMode RegEx$ v+ c" ^- I# Y6 W+ Z
return6 s8 \" G U2 q$ q9 W3 y9 N7 x+ p( N! T
; Stuff to do when Windows Explorer is open
( c2 ]; t6 F7 _4 S6 s; n4 K+ u- z' ^ ;6 `2 r7 t$ W3 m, k. w: b2 f
#IfWinActive ahk_class ExploreWClass|CabinetWClass
8 Y$ k2 @' j4 I% g ; open ‘cmd’ in the current directory) q' s8 D# d. S, T& ^* _
;/ e! A% ?3 B$ b
#c::
, R3 B# g! a' F; E) J OpenCmdInCurrent()
$ c/ Q) T% S4 a1 @3 q0 c1 d. b9 m return( n. S3 {( Y- W7 C8 @, M
#IfWinActive8 t @ m) X0 K) ^4 k+ z. B, [! S
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.& W P' i& u3 A9 ?, c0 [# J+ H+ I
; Note: expecting to be run when the active window is Explorer.
Q" X g& g! U0 i# M# p1 R ;- Z! _5 w% ]' ?$ M: X
OpenCmdInCurrent()
3 y' ^5 E" V+ y: N, W {# ?. P9 [4 m! f* X/ S
; This is required to get the full path of the file from the address bar2 L) l H+ p" X) y8 v
WinGetText, full_path, A
+ y, O9 `: F$ ?" B7 t8 u( H5 j ; Split on newline (`n)
2 F& b# A; {+ b2 J" y StringSplit, word_array, full_path, `n% m& F- T3 Q/ M; n
; Take the first element from the array1 ~2 X, d4 K2 x1 {
full_path = %word_array1%
5 v- ^1 l( ]! L! p1 s ; strip to bare address
, Q; x) E* O7 \& A) r/ w full_path := RegExReplace(full_path, “地址: “, “”)
$ k: G6 R% N9 L0 ]' R2 k ; Just in case – remove all carriage returns (`r)! U6 R, g& d& G- A6 f# d$ M- l
StringReplace, full_path, full_path, `r, , all3 |9 ?" x6 _6 H: U5 T! N$ b
IfInString full_path, \; I: p4 g3 ^, f1 b) x/ d; \
{
- o; g# ?# i9 H: G/ L Run, cmd /K cd /D “%full_path%”
' C A( i; i' i, B }
' C: w& |3 K& H Q else6 I) W. z6 E7 b! a
{
0 p3 R% q- M3 u+ V# C Run, cmd /K cd /D “C:\ ”. I9 X7 M% Q% \/ I6 R. V5 y
}3 c" a( L# ]4 F. p$ {
}
5 k( E# U, @' I U7 ?$ \+ f0 n 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 ]) V* K/ I7 r- w2 g' G 这段小代码肯能有两个你需要修改的地方3 r/ ~& t; b) N
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 ]" N# J3 c$ g/ m+ v2 ` 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: u$ x# y3 V; Y- C: c: @% i) d |