此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 L. a3 U, n6 L0 O+ L: V7 B4 w( D
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。' r2 d: {8 X" _/ N2 s# m8 p
方式一:
0 K$ Y* l9 i/ }9 C" b 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, m3 s( N# k1 X9 Y+ f9 u
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和0 K$ U0 t. E& X
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ Z+ v* x: b; Z4 ~& x. b
方式二:
: [7 T6 c/ `' P+ N' t/ _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:* I9 x9 x) y/ m$ x3 x6 }
SetTitleMatchMode RegEx
0 l1 Z' y6 H/ n t. b return
/ G9 Q2 Y* c, W7 L7 H f ; Stuff to do when Windows Explorer is open& \, K. z3 C0 S* T6 [- o* U
;
# L: @* h# D- T: z# y* _ #IfWinActive ahk_class ExploreWClass|CabinetWClass
( D6 S3 t! G7 A4 K* F; X- w* M ; open ‘cmd’ in the current directory
# S& q* d3 X6 H6 v; Y* S! ` ;
+ v. h% ^4 x# N6 j) q/ X1 o( ]3 K #c::
. f, P7 P' g% ^ OpenCmdInCurrent()& [+ F1 e1 T& ] o
return
+ z: F6 H" p. G. @* b #IfWinActive/ j2 J2 W9 E% V4 Y
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 W I7 Q& r K. {9 ]$ B( f) S3 k ; Note: expecting to be run when the active window is Explorer.7 [) {; q ?$ ^
;& M4 D3 k# N/ }/ d( b/ {8 e* w0 D' P
OpenCmdInCurrent()
- e( u. d) @& @3 b% I( q0 B {
+ I! R. S" I6 [, \6 a9 F. E5 ^ ; This is required to get the full path of the file from the address bar
+ W9 ?! R2 U1 L9 Y& Y WinGetText, full_path, A7 T" K: v5 O f6 E# z' X, L
; Split on newline (`n)
7 K8 N0 J9 E9 [$ N: G$ l( ` StringSplit, word_array, full_path, `n
( v6 A2 x3 S, n$ k ; Take the first element from the array
7 T! g' d6 [: W5 Q6 ^ full_path = %word_array1%
0 [4 F7 E% M! h! Z' ?3 ^; z ; strip to bare address
/ V# b* B7 x% r5 R: K full_path := RegExReplace(full_path, “地址: “, “”)! x$ I0 q4 G5 D, V0 H- Q1 S
; Just in case – remove all carriage returns (`r)8 B4 }. h0 ]* l
StringReplace, full_path, full_path, `r, , all6 @- s v) L! Z' g
IfInString full_path, \
F& l6 y8 _6 y+ s% d$ n7 k" Y {
5 ]3 d# V* X1 E: } Y p Run, cmd /K cd /D “%full_path%”
: X: {7 ~( Y; C& s% Z1 J/ V# h }7 E' _! r" _: a' n: Y
else
0 l& Z2 O9 P u! c& h- K {
8 t ^) T9 E7 Y6 G" N Run, cmd /K cd /D “C:\ ”, M; O6 K0 d5 G+ e9 |4 s) F1 W! `
}# \( Z$ R9 d! G' E8 A
}
. R Z" }( F9 z) b$ l 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( D# u. B# L3 P, S# i# Z 这段小代码肯能有两个你需要修改的地方
5 q% R* d# ^6 h9 Y4 g 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& g @# ?2 `+ H! H9 O 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 [8 v5 y) n& l( x
|