此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* {. m6 S3 ^" m5 r) R0 ], P
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。0 P9 E: h9 W' C( x
方式一:' ~2 R) N% @: J: V
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# Y) R8 J- h* w! i' e9 ~ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 x. I9 z4 \" [# L- {
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 F, Z. n1 c' }! e4 C8 H/ y
方式二:
8 E j* f2 Q' q 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, j: v3 ^0 R& Z
SetTitleMatchMode RegEx
2 }+ ^$ m! w, U1 s2 b6 {/ X return
4 a! }- s0 u6 w- R# t- h" V8 [ ; Stuff to do when Windows Explorer is open& {' [' v% H4 w C) ?3 ]( [& B
;
! y; P/ W K, U5 F: B #IfWinActive ahk_class ExploreWClass|CabinetWClass2 {& D4 C; U0 L' K4 k' O* e
; open ‘cmd’ in the current directory
: s! }4 M) S" L: y3 j& e ;
5 }+ x {/ v0 T7 t9 v8 }' G #c::
6 f/ a# m% a( N2 W) R' c OpenCmdInCurrent()- M" _2 ? w/ y1 c1 N& q- a
return/ f7 @" b X& l Z! W
#IfWinActive
) r0 K( g8 l( E8 g; { ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) u, o+ B- z/ u: t& h# a' _ ; Note: expecting to be run when the active window is Explorer.. ^' @( t! Z/ Y1 ?0 P$ r
;
; [6 M* [5 I5 W. k OpenCmdInCurrent()9 C) d0 ^- d- ^; T/ z0 k
{8 }- e# C8 W. ]2 @* V
; This is required to get the full path of the file from the address bar- P) E! |; K1 T/ v5 f
WinGetText, full_path, A
3 X; p; b% j# i1 I ; Split on newline (`n)
1 a9 z' E' X" A, ~+ U3 V4 K StringSplit, word_array, full_path, `n
" x s9 W+ ?$ a6 G' G$ b ; Take the first element from the array1 [7 Z$ s: z8 v& }
full_path = %word_array1%
5 |7 G5 P- T [ ; strip to bare address
5 a' U" L- B5 h3 I- n8 L# z" J full_path := RegExReplace(full_path, “地址: “, “”)
3 j; q' f, v* k/ d ; Just in case – remove all carriage returns (`r)
* k7 d: U- f% l/ X4 ?5 j1 s3 M6 h StringReplace, full_path, full_path, `r, , all4 \8 j* F6 }( a3 ?2 G
IfInString full_path, \
) t( x* u: Y* K5 u: E" I {- P) a& n+ G9 X$ v$ E
Run, cmd /K cd /D “%full_path%”9 x. P4 Q# ~% q' U, e" ]
}
! p9 P$ _7 }! \: H! n else4 q! ?' `1 n& X3 g/ k
{
; O" V. G6 o9 ? Run, cmd /K cd /D “C:\ ”& ~3 \. _3 a2 ^$ p% n
}
2 ~! m, v1 C7 d' ]+ P! b: Z1 I }+ J3 y' U& D7 v r- ?2 a
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。$ B* Q8 K* F7 m; x
这段小代码肯能有两个你需要修改的地方
* N# Y1 G: O3 |0 k: f 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
/ C9 s( C& N$ i6 c4 J* _ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 i* w7 l1 j' `: e5 O( h |