此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 ~4 E- I. l! s/ W 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。0 V X; K7 C" z U
方式一:
0 X: F4 A7 x3 P& i: } 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 Y' P! |; x, T) M3 y, R! R
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( N& x" E' z! J/ z+ P7 ] HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 \' A8 g' c! x: ]5 i
方式二:
6 u0 J# \' A" V% r: u1 I% h2 a3 ^ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 P( B# B4 O% A+ F
SetTitleMatchMode RegEx
* I1 @8 ?: l. S, m0 `$ E return
! r& Y# q* N# i! w ; Stuff to do when Windows Explorer is open( S+ B$ m4 j6 f4 t/ z
;
, }5 G- ?3 L+ D) w #IfWinActive ahk_class ExploreWClass|CabinetWClass
. c( k1 }& y, T3 P& J ; open ‘cmd’ in the current directory4 S# \6 r; T2 a0 g+ Y6 ]. G& p' E
;
D" s4 V! ?2 H9 [+ q8 U #c::8 o d' @$ A# P1 \
OpenCmdInCurrent()0 |/ o P6 d" C
return: f H+ {! {! A4 H
#IfWinActive
( |( V) x% R4 C ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. j# Z7 n1 Z- D ; Note: expecting to be run when the active window is Explorer., I& @4 F; g2 n3 F
;" n1 {/ e5 u- U1 I. O8 h
OpenCmdInCurrent()5 L | z- g; H+ a+ k5 x
{
. Z) p( [& B6 d8 b6 { ; This is required to get the full path of the file from the address bar8 v0 F n: Y$ J: `& u6 q6 [
WinGetText, full_path, A6 v' s$ x; @0 e
; Split on newline (`n)
, t& G7 r( A O& j1 G j$ F8 M* ~; S StringSplit, word_array, full_path, `n0 T8 N* X: V2 z+ f! d2 C. |( U) C
; Take the first element from the array( T! ?& j6 j, ^3 ~; H- z7 P* D
full_path = %word_array1%
# M; \7 [$ @6 ], B& k8 K. A5 D7 E ; strip to bare address( o5 Z5 n; r+ p( x% R/ E4 P9 T2 I+ J
full_path := RegExReplace(full_path, “地址: “, “”)' j$ N8 d X2 q" N! e# Z0 ~
; Just in case – remove all carriage returns (`r)
. E7 N& a4 h0 e9 t StringReplace, full_path, full_path, `r, , all
: d2 D0 l! u6 i9 s0 d, f. m& H5 C IfInString full_path, \+ X+ b5 B4 t" K* Z; `6 j$ i/ N
{# D9 F$ J) F8 l
Run, cmd /K cd /D “%full_path%”' A# P& ?/ R( D n H& D( a' E
}
2 E6 w/ U6 }, d3 x0 N else
4 a. ?2 ~, @ P. m( e {
+ |, ]0 D, q4 t1 X& i: x Run, cmd /K cd /D “C:\ ”$ H: J5 L2 Z! G+ ^7 [) z
}
$ u4 a6 z- m2 l. O: K0 H' [% U) L. p' d }' L6 h* Z( ^, i8 H6 Q
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" p# m/ L7 t& P% w, C3 T0 @2 s; b 这段小代码肯能有两个你需要修改的地方
8 h' r6 y4 R% E/ p$ @3 N" s4 X, F 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键" S' c8 W K3 e) x, g. P8 O
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 \/ D$ Y: j& f5 S. z |