此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ l1 j( P `% @ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。0 b' ?8 w/ p& a
方式一:- D z6 T& }; ~* M4 _- N+ J9 _ a3 H
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& Q, M: S0 D5 N ?# L/ G 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" E1 {/ p/ G- ?1 v( [/ n
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" @$ q+ g0 m2 p: I; H0 | 方式二:
. t# f8 r# `$ c0 Y" m 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 \% ^$ C" W' t1 \
SetTitleMatchMode RegEx
) _ Y( c; _( e: g* | return/ Z; Q) ~" i, y4 k
; Stuff to do when Windows Explorer is open
6 k$ B1 R1 H" y' p. a ;" t0 B2 N4 e3 O. e- O: ]# Z' I
#IfWinActive ahk_class ExploreWClass|CabinetWClass7 Z5 }" ?4 D* Z
; open ‘cmd’ in the current directory7 l) e2 B, }0 a9 A- w
;
* s3 S9 b4 X' y' P) c #c::
+ @. @1 u. E3 b+ K* N- i# F OpenCmdInCurrent(); F- a1 L+ [5 {4 g( o
return
' v* h: O* U, x9 ~& y #IfWinActive+ @5 d- Y7 {$ G9 M+ C/ F
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 l2 ?1 h) a# x3 l4 ` ; Note: expecting to be run when the active window is Explorer.
# u" O9 |% V: B2 ~6 E1 c( |0 c ;
- a1 b u) ^5 s7 _ w7 Z OpenCmdInCurrent(): L4 J8 R1 ]' N: a5 U1 T- Z
{+ F( _$ d) ]8 B8 G
; This is required to get the full path of the file from the address bar! O0 K& m/ h& M; s
WinGetText, full_path, A* W# L) |! r% k, O6 }3 ^
; Split on newline (`n)
5 s8 b0 V8 |" K4 ^. k v! l StringSplit, word_array, full_path, `n
4 S! Z* ~, P- r5 q* ^ P5 @) \; x ; Take the first element from the array0 _: O: Q, K* g! i e
full_path = %word_array1%) P+ Q* e% b5 w. X, N2 U& o
; strip to bare address# n* `/ o3 M5 c+ j a/ ]
full_path := RegExReplace(full_path, “地址: “, “”)
! B4 `+ r3 o: q ; Just in case – remove all carriage returns (`r)4 o. s/ H# J* r5 P" b
StringReplace, full_path, full_path, `r, , all
! _# `& W( }. i( i4 s, m IfInString full_path, \
( E) v: @. R g2 G+ f {& g! l+ S( w" `. {- y
Run, cmd /K cd /D “%full_path%”- y; h' Z% M" a6 v Q
}$ I" k( Z' v8 R4 K
else
4 R; n9 H: k* h, @" h {; q+ M, Y6 t5 ^. ]7 C! x
Run, cmd /K cd /D “C:\ ”
$ j9 `+ w, |' w2 x }! L% y# C# g# V0 o1 z
}5 L0 A2 d$ \* {
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 v- {+ }- k5 F' \; ?5 D4 z
这段小代码肯能有两个你需要修改的地方
* |. ?; v3 r4 V( A! i 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
6 N( a) Z. j, j, C 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
6 R" g, ~- m& k |