此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) r5 S, r4 |( ~7 a ]% ~1 w
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 i! h) N* `3 R8 Q3 F" a4 Y7 } 方式一:. p4 e- K+ _* L) v. N
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 R X: |# q( b) x8 T0 W
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! @% _% d* S: P% w
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。% ]9 ]4 C8 n/ U! {% f1 b5 O0 `( ^
方式二:
" ~( T. R8 i8 j) v2 Q 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( Y+ |$ O f! ]4 e: G& y
SetTitleMatchMode RegEx" ?8 f! s/ I$ I; Y& [# k) ^3 Z
return9 K8 e# F% \& z* n1 X/ l
; Stuff to do when Windows Explorer is open; X& [# N a4 x) S; {& I7 e
;% l, r7 v2 C; m
#IfWinActive ahk_class ExploreWClass|CabinetWClass3 Q3 \/ P- g% P4 x4 @: d, Q
; open ‘cmd’ in the current directory
$ F8 S3 z! {: t/ g# Z ;9 Z/ o( T# J, \
#c::( O4 T- y) p- _7 Y0 J1 d6 s9 e6 R6 o# n
OpenCmdInCurrent(). c/ ?0 Q3 Y3 z V9 I
return+ Q" i- Z1 S( }1 f1 w
#IfWinActive" Q3 Q/ d$ n6 y/ e! B" C" Y
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 P" J1 y. d E! y+ y
; Note: expecting to be run when the active window is Explorer.4 l* z, }0 c) B6 z! d/ M- L
;1 \8 _- Y9 v, X* a [
OpenCmdInCurrent()0 u: W1 r1 n& z6 W) L0 X/ |/ U
{! I- m% `: ^- u
; This is required to get the full path of the file from the address bar+ U4 M9 A5 m: Y# g+ D" _
WinGetText, full_path, A
; J1 G) f6 i% _! Z' H ; Split on newline (`n)
) C- q, R f" S- ` StringSplit, word_array, full_path, `n6 F4 t0 L- O! F( d8 f( Q$ P
; Take the first element from the array, ^4 o1 ]6 B% B+ X7 L0 B
full_path = %word_array1%
% l. S. X6 h4 T$ t ; strip to bare address
2 s/ Y% d+ t1 t% P, ], Q& v7 a full_path := RegExReplace(full_path, “地址: “, “”)$ z$ |8 C% T$ i/ Y8 K& ~5 x
; Just in case – remove all carriage returns (`r)! O2 a, o& j* Q
StringReplace, full_path, full_path, `r, , all
9 _4 X% m- r1 `0 K IfInString full_path, \
$ M, l, F, Y3 } {
' E% B- T5 B. j5 v0 B: A! j Run, cmd /K cd /D “%full_path%”
# R2 W/ C9 ?' Y9 J6 p8 `9 _- I6 A$ S3 { }( p+ `( K/ E4 \0 y3 X: @" t
else% H/ n3 w7 H" D( J
{, X6 Q, Q" c: J" ]7 k
Run, cmd /K cd /D “C:\ ”
- ?) B" l4 A4 c1 _1 v }
% W; _! S2 B3 |6 j* C }
" g- r- ^& G+ ]9 O0 t# I& M+ l. Q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
+ i. N" ~& |8 u3 W0 i1 y 这段小代码肯能有两个你需要修改的地方
; t$ F! V! o# s/ C! R3 [# l$ A 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键, m6 R6 G+ K5 D4 [- y; P
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “7 d$ u1 w; l+ n/ ~: b8 X7 X
|