此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: W. A. S/ h6 p& l
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
; o3 k. \: t3 w5 |% P2 i# G 方式一:
# T3 i$ u2 m8 c 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,' r( _; N& ?4 ~
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 s: i# G ]1 l7 q. q5 @+ G4 _$ w$ c1 f
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
, d' |& }2 P$ K9 i& s5 Q 方式二:
5 `$ H, N6 \! P% e4 L 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ v; `! c% v/ r5 @5 Z SetTitleMatchMode RegEx) P- c1 N' t B4 q' B- d
return o3 u% b7 `7 k6 _* ~
; Stuff to do when Windows Explorer is open1 |7 U0 I1 h5 D" D3 Z; r; S
;
& W$ U6 U$ r; ?0 d! k) Y) } #IfWinActive ahk_class ExploreWClass|CabinetWClass
1 @' Q5 O7 M8 V+ q+ d ; open ‘cmd’ in the current directory) W, I3 Y, d$ X1 B# y3 [
;1 {& @$ C, S3 D4 f
#c::0 ^: `/ v- y2 H3 _/ L, B
OpenCmdInCurrent()
. F; M% Y# }. c% r return
( s7 z K" d* N9 ` #IfWinActive6 n0 m1 Z: Y3 p9 p, N( i' m0 b
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 P. U' ?0 |8 G7 S) O! l; P
; Note: expecting to be run when the active window is Explorer.
$ V& E% v& `7 {: [& X, X ;
; H9 ^3 n y8 @% |4 h. V OpenCmdInCurrent()
# ~) G. t- ^6 m' F9 l {
; V8 @% r+ q! G8 u. V ; This is required to get the full path of the file from the address bar# L; L Y5 X% q& G/ s; O
WinGetText, full_path, A/ }. U$ |* X2 X$ m$ U: p
; Split on newline (`n)+ K. h/ B8 O0 T& q! I b1 C
StringSplit, word_array, full_path, `n
% N: `; t; M) i; g7 n ; Take the first element from the array: s/ g/ U" i8 m+ N7 Y
full_path = %word_array1%! a9 l% ?9 H# P
; strip to bare address
8 O, X0 a' |# x# l. H# i full_path := RegExReplace(full_path, “地址: “, “”)
* e7 a8 d' \, K9 B! i+ w! D1 { ; Just in case – remove all carriage returns (`r)9 M' t0 Y. ~6 n4 I' q" K. O
StringReplace, full_path, full_path, `r, , all
% n2 n8 J, W! F& ] IfInString full_path, \' F/ x" ]6 D% t, o1 u) x$ l, o
{, r" R( U. v" V1 U- I
Run, cmd /K cd /D “%full_path%”( S! A3 j& ?/ F8 \, u$ S
}
; ?) c m/ {) W% c4 L$ }- k else2 i5 q+ I5 h- P- J0 V. e
{
( q& A2 O2 O) Z" L( S0 l Run, cmd /K cd /D “C:\ ”7 `% n/ R1 c7 p/ ]! {
}
2 p, Y7 `. K# `0 U. a }
3 e" h4 B% {; n5 f( j 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% {1 b1 X0 N# L* E: q; @
这段小代码肯能有两个你需要修改的地方
* x: J4 L$ r! |2 E/ W9 Q 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; y# G; Y6 \1 \# x- J* Y" o8 _1 V# Q 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ Z6 V# y" P+ ~( d |