此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' `; J8 |& X/ [4 M1 |: l+ [( l/ v
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 e6 ^# U$ D7 p l0 G$ H
方式一:" ~% L( {0 {* j3 Y% `6 w
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 o5 X* b6 c) O3 m& D
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" o8 S* P x0 h+ N+ n" \7 v1 C
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。 Y. q- f* Q, \! M3 _& n, ~
方式二:
. t" ~; w1 E1 l% \7 [$ B 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 L- J6 \+ c3 v1 j
SetTitleMatchMode RegEx
. J9 K0 F& i6 x/ h5 G$ M return! T8 M& y& L- z
; Stuff to do when Windows Explorer is open1 t% y4 }8 i$ N7 @. {) A
;8 B" ~% a; T" c/ W
#IfWinActive ahk_class ExploreWClass|CabinetWClass3 Z) ]% \, Z4 i4 ~1 M0 _& \. I. L
; open ‘cmd’ in the current directory
! m9 b5 W$ v6 I$ a9 ` ;
. f$ z9 `/ R0 E# e #c::
& P$ _3 M4 t1 {. l8 F4 @' d OpenCmdInCurrent()9 j3 i5 V) ^# F' ^
return+ q$ q4 H# o0 e' F; U e
#IfWinActive
* u I$ _' }' X' e" o1 t" c* N$ X ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.. S4 J1 q6 C7 D' C/ p" Y" g
; Note: expecting to be run when the active window is Explorer.; J |+ @7 U1 V
;6 U* I7 y0 o( h
OpenCmdInCurrent()6 y5 X1 w# t! C }, y v) v8 b
{* m9 g1 t2 P* t9 F; h, _; n9 r
; This is required to get the full path of the file from the address bar
4 D+ H! B: _' } D WinGetText, full_path, A# E1 S' [1 L; I7 z% { I
; Split on newline (`n)
3 P4 ~+ i* z& r StringSplit, word_array, full_path, `n% @; n3 A" l% e1 \
; Take the first element from the array
0 W2 C5 S0 ^4 W full_path = %word_array1%
* T7 ]6 }6 ^5 B7 d ; strip to bare address
% V# c2 w9 _" v; [' u( b R full_path := RegExReplace(full_path, “地址: “, “”)
( q) g( d$ Q. a ; Just in case – remove all carriage returns (`r)2 T7 T# T( D7 Z' N2 E% o3 B
StringReplace, full_path, full_path, `r, , all
$ U: B' x" L4 {1 q% J IfInString full_path, \' ?( T5 N7 q, J6 w' D) R* O
{
+ }3 H$ f' A( P, b. o Run, cmd /K cd /D “%full_path%”# n" X# f% W2 d& b7 L! t5 e
}
8 w3 q! K7 M. T' O/ Z9 y else
7 k; l" f+ E) d" o5 p1 m' G& @7 M {
5 c- P# n B8 [- F Run, cmd /K cd /D “C:\ ”
" V+ B" r8 X6 \) t' h }
) w8 ?0 h- w2 N0 G- O! X }; J# r4 Y/ R5 p: o( M3 y' h
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 X& y# `% L: F
这段小代码肯能有两个你需要修改的地方: z; E. H* t1 k- w/ ]
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 @6 C9 p) s- |, S: M( f 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “6 d9 \- Q1 V) p" V- b" @
|