此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( F* S" X _' n9 J# q( x9 U2 K
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。( b& U7 l7 X, k0 F) a$ \
方式一:
6 S5 w- L2 [* X7 j/ ^! F 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 M- \+ e$ W% `$ \: d& k4 _ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 X- Z; Y* G' e0 C6 B; h6 Z. e" K
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ j3 U/ C `- b+ W" b 方式二:
7 S8 e- y; C; u" h& |( L 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
' y: C- F6 ]7 G- Q SetTitleMatchMode RegEx
$ w1 h8 ]4 d& Y/ V. b% ` return5 k9 n2 e/ [* D P
; Stuff to do when Windows Explorer is open
3 W' f9 C: {1 ]. I+ J; g: a9 Y0 {5 d" y ;
+ s" P( O" W6 O4 I+ p9 m #IfWinActive ahk_class ExploreWClass|CabinetWClass
8 I1 d, H! R' v, S8 { ; open ‘cmd’ in the current directory$ j& X9 _- Y% t6 }7 w4 L
;
1 Q, q0 X6 A; P+ W #c::1 S% y1 ^8 w s+ N2 o: @$ I
OpenCmdInCurrent()
# ~, f8 I: s& d" g; L return
! j+ W5 N( Z" h6 H0 }7 z #IfWinActive
: Z. @, M9 e: ^, ~5 Y7 A8 S ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 X, ]6 U# B; {; r
; Note: expecting to be run when the active window is Explorer.. o, G5 C: o5 E8 V" m8 f+ }
;3 h4 m" j( M, t8 E8 g V
OpenCmdInCurrent()6 K& C3 |# t7 `) ~! Z
{1 ?6 p' s" s1 K* l& S
; This is required to get the full path of the file from the address bar5 O" v, s9 W4 b8 G; M7 @
WinGetText, full_path, A
5 Z. N# t7 H6 H- A& C ; Split on newline (`n)
+ l9 `, b9 G/ r6 `: G# I StringSplit, word_array, full_path, `n( t. z$ \6 s4 l% w* b
; Take the first element from the array
# I1 k. w) ? c$ M% w a full_path = %word_array1%
5 w5 e( U) z; S ; strip to bare address
w7 `: d# d: h. q full_path := RegExReplace(full_path, “地址: “, “”)
. m! m$ d+ m% d9 Y6 a% ^ ; Just in case – remove all carriage returns (`r)( J4 L8 O6 h! Z- A* _6 {
StringReplace, full_path, full_path, `r, , all8 M0 s: ~# u" e2 L0 M+ ~/ H8 d
IfInString full_path, \2 Z. l: r' I# ]* e* \, X+ V g0 f
{7 w0 S5 h# W1 G9 q
Run, cmd /K cd /D “%full_path%”$ ~! X' N5 {+ }. S
}
3 G: X' t2 o. w4 | else
( v* {( A2 u# X) `2 r" V {
- S1 y) j; J+ [1 h E& } Run, cmd /K cd /D “C:\ ”0 E9 Y, W. F6 m; s9 u* B
}. f7 Z2 M+ w% _, f+ I+ }
}# B3 T7 _9 n; z
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& [$ I# c' }% o1 G2 x5 F# g) N 这段小代码肯能有两个你需要修改的地方5 `# x4 X8 n& i7 X% w. ~& R
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 J7 ?# e: D% Y, a3 V6 K S% g 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; K1 c* t# E0 |# H' Z+ \ U* q |