此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; S4 w- v2 ]* d. s$ ^
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 w5 C9 b/ Z% T; _ 方式一:* ^8 B1 f9 A( ]
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, n' ^' n7 L, F% s9 [
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 g8 N+ G2 _# h" W0 i2 d R9 x
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
T1 b& W3 ^% x; f6 W 方式二:
/ |! T) V4 U+ t2 q 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:$ a" ]- f9 g3 A2 h
SetTitleMatchMode RegEx* E8 `! K& k) F( H0 }( p
return
; E- e4 s3 H' y7 z; {3 D ; Stuff to do when Windows Explorer is open
! A, t ]$ o) m z ;% @$ u$ A; `8 l
#IfWinActive ahk_class ExploreWClass|CabinetWClass
/ h( y2 r9 Y4 L3 r5 _ ; open ‘cmd’ in the current directory
5 a* B: Z$ \; i% B A ;5 r) T. n0 N5 ~
#c::! J- I& c1 ~6 b" Y$ u$ p5 T0 N3 Z- _
OpenCmdInCurrent()! J. Z/ Z9 Z9 ?" M
return( _+ {& H2 D5 f
#IfWinActive5 O1 ?' ^1 J, o
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 m0 j: b) I6 j7 F. v( J U6 E: b
; Note: expecting to be run when the active window is Explorer.
3 I, a. c) l. P& ]5 g ;5 {; T5 l. n+ ^3 y! z1 @1 h
OpenCmdInCurrent()
4 {: D$ U( d. d% h' f# ~2 `" @ {2 d* L+ X& e, o+ e1 J+ H
; This is required to get the full path of the file from the address bar& f! o1 v4 q7 {7 y8 H z) h
WinGetText, full_path, A4 Y5 a# N8 c6 q6 J
; Split on newline (`n)
4 j6 `: |8 L3 l: I+ [, u, s StringSplit, word_array, full_path, `n
1 F7 v& N; i2 {( Z ; Take the first element from the array( s% S) d. R. N
full_path = %word_array1%
f7 g- x, s( e: C, n4 b ; strip to bare address7 m4 J- P# c0 e% U& F
full_path := RegExReplace(full_path, “地址: “, “”) I! @& G- k+ `& ^
; Just in case – remove all carriage returns (`r)
! }: o- y5 ], u, C$ V StringReplace, full_path, full_path, `r, , all
i0 G/ o) a1 a9 b M8 o* | IfInString full_path, \
- X, \7 K6 y& p* L' D a {
; ~! M7 W' [6 d6 ~8 ?* k" j3 I Run, cmd /K cd /D “%full_path%”
" R+ {$ s- @: u( T' P }
- ]/ X/ C+ V# L4 h/ C ?# p+ x else
5 v) Q: S7 c: ]. e( @" }+ j {
' p; G9 r9 e& _7 w* E! E Run, cmd /K cd /D “C:\ ”, b2 _4 } y1 E- G
}, V6 \7 ?# [/ Q r) b0 A
}7 T: q! T( d% }" d+ j) X. t, D* w
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& [8 }7 B! ?! b6 |5 X7 O
这段小代码肯能有两个你需要修改的地方
e [9 b; O' t 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ ?# x/ J9 ~5 U1 r9 q" P2 C. ~" B9 p 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: `+ ^) I2 T0 g. m
|