此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. S- e7 ^) ~! _! |5 x
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: ]4 V' j' C" o6 h$ J+ l
方式一:
: ? q, [8 D6 P& s! B. O& T) ^ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: c2 L: J5 T% R
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 X6 k5 c+ p6 x0 z9 D
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
0 P* O# g4 e0 L7 w 方式二: j2 M" g0 {9 s8 |) R
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:0 |5 s8 g5 v% t0 ]5 g+ ]2 N6 s
SetTitleMatchMode RegEx4 _* ]1 ] G5 g, Z6 ]7 T( ?
return
! L# U' z Q7 O6 ^ ; Stuff to do when Windows Explorer is open
4 h& m( D0 F9 q( b: c4 w: { ;
1 O, o3 w, J; T. |7 J2 { #IfWinActive ahk_class ExploreWClass|CabinetWClass$ O% @0 ?) r# [: _- R$ a
; open ‘cmd’ in the current directory
9 `* B7 \- `- A0 _8 Z$ p* k ;
* x( f( G( V$ E3 f, J+ S) P #c::/ J- h1 V8 T: c U* Z
OpenCmdInCurrent(). [( Q" A* j& O; _7 W
return
: K: Y) b$ h% O3 {$ k$ m' \& Q #IfWinActive) b& {# Y) M* f1 W$ J/ ]
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.4 C6 W/ [: D, r% Y6 I- i
; Note: expecting to be run when the active window is Explorer.
5 q) b0 Y3 r* K9 i ;' n* I, K; D4 u+ _1 O5 F- U) Y
OpenCmdInCurrent()
! d$ J! y( Z- F {
, H: j" F7 b7 l( n/ g$ i1 ]# S ; This is required to get the full path of the file from the address bar1 b7 @# n2 `5 d: B* z' S
WinGetText, full_path, A
5 d8 G u g$ p: W- V% H9 @- c ; Split on newline (`n)( ?+ E, @: D* q5 G( K) L
StringSplit, word_array, full_path, `n
, L5 z2 H! v) x- ~0 K d ; Take the first element from the array
6 g; H7 J0 e8 d3 c; V3 U2 L* t full_path = %word_array1%
" L' r% f9 g% v4 s' D- I7 m2 |9 H ; strip to bare address
$ ]& [1 o* W( g+ j$ e- N" g. _7 j full_path := RegExReplace(full_path, “地址: “, “”)
7 i# j- e2 B6 H1 L: E ; Just in case – remove all carriage returns (`r)" J. U! t6 B2 Z/ ]+ @' Q8 x$ ~1 t
StringReplace, full_path, full_path, `r, , all
w$ }8 Q9 P8 A' t* f IfInString full_path, \
- E, Y Z' x5 \, G; \ {: [& D7 C, i, t; ?
Run, cmd /K cd /D “%full_path%”
( `/ Q/ C% Z' C4 e% c' B' _1 A6 ] }/ s m. x) ~2 V
else
4 C9 S. I, \! m7 E z {
. {' P+ L2 [. y6 G7 F. U7 @# @/ @ Run, cmd /K cd /D “C:\ ”, P/ s5 D$ \% E! a
}6 k$ ~, h `( o) r$ F
}+ n( s- V3 { v; |& C( S2 v+ ?/ T
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& B+ s" M2 C7 h" {/ M9 t; f; } 这段小代码肯能有两个你需要修改的地方: o" l* W8 }2 ]$ h
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% i* E. {* j! Y0 l4 _5 X# f
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* q0 [) i3 Q2 T4 z+ h9 ]* Q$ a |