此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% |+ q& J+ Q* q; M. p6 `5 r
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
. N7 s5 M, u9 r5 j r) z- C4 Z 方式一:
, j' h+ K, s3 F- `* [4 I 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 r1 o4 S5 E3 C$ o, C( T8 [4 }
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ U. S; a8 |( O. U. s) B
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
: ]+ N/ ^0 Y; N/ m% x$ `7 P 方式二:: p$ C1 E( r1 Q" [
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" i; h4 r3 b: R
SetTitleMatchMode RegEx
* ?9 t! \, U ~* H return( Q) H) y8 R: \) u& \7 C" w, p. A
; Stuff to do when Windows Explorer is open
$ d9 m$ m% @6 V/ c, \% { ;9 ^( F9 @; K" {0 T8 z2 t4 z
#IfWinActive ahk_class ExploreWClass|CabinetWClass
& w8 x# M( l2 M% N6 B$ R( N ; open ‘cmd’ in the current directory1 @$ S& I$ u1 } _
;8 f- C) W9 E; A& o8 y2 x4 u+ G7 ^, I
#c::( c, B2 \% f) b4 p6 I% N
OpenCmdInCurrent()- R6 a7 e% _4 u, I3 z0 \
return. B. k* w& {0 q% i/ \
#IfWinActive/ d, `: B" z- U; [ k4 v# A
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 |; n; I1 r) X9 G. _: n
; Note: expecting to be run when the active window is Explorer.
" t% K- V0 B3 Z4 w$ V/ T ;; A$ S( n; p3 U) S% Y( w1 _: ]
OpenCmdInCurrent(), n" H: Q* s0 }& E0 m
{9 I- T' H1 n/ A$ A" K }
; This is required to get the full path of the file from the address bar' ]; I+ h( [+ \% J2 F5 |" D6 F
WinGetText, full_path, A
+ E% |( u4 k& q) F$ m w i# z ; Split on newline (`n)' \! z! r8 t: J8 R/ v2 x
StringSplit, word_array, full_path, `n
! i& n- n9 U$ p% M; R- `9 E ; Take the first element from the array
/ X" h, b! M, x& J$ D! X" F full_path = %word_array1%
5 J6 i, b. u2 W3 a$ l ; strip to bare address3 w2 s/ z/ [9 R& n1 F) v
full_path := RegExReplace(full_path, “地址: “, “”)
9 V8 [( v/ _& Q ; Just in case – remove all carriage returns (`r); F. d6 p( v N3 Y8 t$ x
StringReplace, full_path, full_path, `r, , all5 O3 J" H) f, J, g
IfInString full_path, \- O& Z. m( {* q* }$ a1 ^& r6 s
{. K( z: ]% a' Q3 G7 g
Run, cmd /K cd /D “%full_path%”1 H- `) R2 {( a; T
}
$ |0 H8 K3 S! r5 L: \( Z, j4 ] else# S/ H6 Z- m5 G3 s$ b4 v, {
{
* [5 x* D6 z, X8 m Run, cmd /K cd /D “C:\ ”
3 c* q6 W1 w9 I }0 j' d. Y( Q l+ r/ z
}
# f0 _/ Z3 {0 i2 n 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& p; P2 W7 P) f4 f 这段小代码肯能有两个你需要修改的地方
3 _6 F. l" V" y: _/ i 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% f9 Y8 y5 a% d( ?$ V 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 d( y' [. \/ q
|