此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。- \# o! ~1 k( K/ p+ I( T/ _8 F
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。+ B1 t+ I: j$ u: P
方式一:
3 T$ @" o Q. Z- D | 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
, S5 h9 M2 \$ X0 I/ n+ [9 @ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, j5 l) ?( F1 U: R. `/ o+ b0 q HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 a5 v# L/ \ ]) X& H7 n0 Q1 I8 E 方式二:- q# k. \8 V% R0 H& a# r
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
~6 `6 b- O, @3 N1 C SetTitleMatchMode RegEx% q+ G4 } `. F/ W) H3 v/ N( L# h
return
2 u7 ]0 |5 k$ F: { ` ; Stuff to do when Windows Explorer is open1 R$ A( H+ H, R- C
;8 l0 d+ [# q$ y/ \ S& W
#IfWinActive ahk_class ExploreWClass|CabinetWClass
* A# b0 K( [6 z1 f" U. Q ; open ‘cmd’ in the current directory
; V: U% M" I5 Z5 a ;
/ L U5 j1 x, K6 K2 i #c::
0 h' Q* t& D$ y# u& V8 n8 M* D D3 Y OpenCmdInCurrent()$ I9 y: |; [2 X3 r% ]5 u
return
( S5 G6 A8 \* }- ]6 j. I$ w% l #IfWinActive
. h; t4 L; r4 }# L% F+ e ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
" }, s c _5 Q/ ^- k/ ^ ; Note: expecting to be run when the active window is Explorer.; g$ f$ u. t$ o% e
;
3 F. ^) N F# L% }1 e' X5 Y OpenCmdInCurrent(). ^9 F+ `! G" o X
{. d: h' r4 K8 O2 b" e8 [
; This is required to get the full path of the file from the address bar
6 `* I8 x, J* i6 j8 U7 @ WinGetText, full_path, A( o6 J; `/ }1 i) b2 X
; Split on newline (`n)% |7 M4 r8 y1 [8 }8 w, b* A d
StringSplit, word_array, full_path, `n- y" z3 M: z. s; P3 z5 \
; Take the first element from the array
: }" Q3 e$ I/ i3 D* o full_path = %word_array1%9 o4 j5 @8 w4 l1 M2 K) w& z
; strip to bare address/ w3 W. {9 f( H% P& D& Y
full_path := RegExReplace(full_path, “地址: “, “”)
' H0 ^' T' d" a- g; k$ J- ~! _ ; Just in case – remove all carriage returns (`r)- C- e+ H/ P7 }- a" r2 l
StringReplace, full_path, full_path, `r, , all
, K, P) P6 F$ r% @ d- |* Q1 V0 n/ K IfInString full_path, \
8 y5 E) F1 C0 G8 {! J5 Y0 \8 u {
a$ x; Z/ I# ?, \. n4 [2 s Run, cmd /K cd /D “%full_path%”# `$ P: t$ [9 s6 U
}
& I$ H/ V) i. F A/ s3 Q else! j& _( @4 Y& s- M1 _1 u
{
* I. O& R9 B8 g ?( w7 \" v Run, cmd /K cd /D “C:\ ”8 H+ p3 \8 g) U
}
1 D$ S' C! V: t4 ]1 V6 _/ X+ J( U }' ?4 {6 g6 w$ ~- r* i
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- r5 {& Y9 A/ u% [& T
这段小代码肯能有两个你需要修改的地方
( k/ `- G W$ p+ T, \; i. } 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键: R% |4 B& G" P v: A) L
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# A1 U% y; N. f- S# I. N3 v
|