此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。5 E9 o+ K# z) J& @, }
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。0 z/ E" D) g7 h: l( A
方式一:4 i% u' y7 U; B& E8 y8 S( A
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
1 g* ~$ T, n& I8 M+ I1 ` 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' U p8 i6 w2 X! D
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。' `2 l! i1 U( s: p
方式二:
, \5 m* h9 |) B# G- P) e, f$ { 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, d8 ?$ e/ M" b SetTitleMatchMode RegEx3 N% C; t/ b# c/ N* z& B
return
# M" J/ l/ ], C8 C$ R8 a ; Stuff to do when Windows Explorer is open! D4 x" p7 I$ a8 O7 d
;
9 h) r, [. M9 b: D- [ #IfWinActive ahk_class ExploreWClass|CabinetWClass: y) g4 Z' ~0 k
; open ‘cmd’ in the current directory) W% p6 Y2 a% _% S% x' _8 E" E
;! M3 l! y2 P# C2 f% q! i. [) c
#c::1 x. a2 e4 C' J
OpenCmdInCurrent()
2 y5 V( m! Z! ]3 F5 Y2 } return0 c2 G& J# x2 @* a0 R. ^
#IfWinActive
3 y2 }. y f. R$ D. f2 J ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# }+ |, D5 F" g6 {( v2 G
; Note: expecting to be run when the active window is Explorer.
# ~ b1 M3 r& a7 a5 ]1 E ;) V( K5 b3 I% ^6 e
OpenCmdInCurrent()' J% | ]% \! ^; T! l
{
: u8 h9 P% q4 K ; This is required to get the full path of the file from the address bar
( d7 B$ h3 d$ _, ?9 K# h WinGetText, full_path, A6 k+ ^" }4 M4 K2 U2 f
; Split on newline (`n)
$ `( D/ W' F7 F. q3 I StringSplit, word_array, full_path, `n
4 N* r6 l6 M( R. ?7 n+ i ; Take the first element from the array
! o2 i) v/ r, U$ j) x) ~* L5 Z full_path = %word_array1%
/ ~* Z6 F" s/ S, n' g3 L: ]; g+ z ; strip to bare address- M) W' p( J- Q: g
full_path := RegExReplace(full_path, “地址: “, “”)' K6 W P4 L$ h5 D$ l5 n
; Just in case – remove all carriage returns (`r)$ @1 T' @' E- z2 `
StringReplace, full_path, full_path, `r, , all
! c& S: i- N: W' F P0 W IfInString full_path, \! a! ]+ b' i2 R
{
9 |7 d* @4 M. z; r+ K7 v Run, cmd /K cd /D “%full_path%”
1 |/ e9 q4 V- [. t; d/ Y7 C1 D }
4 r: B5 v9 z4 o/ r* M4 w/ k else
$ [( k# }0 K4 d8 c! I7 |6 i {
! W" l$ \4 C% v) L8 `- h3 }# } Run, cmd /K cd /D “C:\ ”
R* ~( N- {9 e5 _4 [( N; I) s } F8 W" w/ Z9 |7 e
}
' N& T% F. U7 ]/ o( E2 E 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! ^: E# y9 B. P
这段小代码肯能有两个你需要修改的地方
) l" L+ q% |/ m0 e+ z7 O+ `5 s% G 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 h1 M& |4 F' ]8 k2 T1 Y 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “% H4 T5 ?- b3 n$ m0 g# F
|