此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% h. [- ^3 L. X8 |. k6 z d 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。( ?; c. S/ e+ r0 a8 B6 H- F: Y, w
方式一:, z, J/ N# v9 ~4 g; Y7 Y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% R$ g) {9 p* S* G6 [$ A0 O 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
% E0 J& m! _5 ^7 m6 o HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
# d( L5 e8 l& H7 i f# t 方式二:
7 H+ A7 i3 Z9 x. [3 M 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 ~1 \$ B: x; a, x; K
SetTitleMatchMode RegEx
( i5 r9 |+ y3 ]8 b/ p, v return0 p: \+ P+ M( n# t
; Stuff to do when Windows Explorer is open
# D+ K8 s/ a/ k ;
* F# u* K2 f% \* S #IfWinActive ahk_class ExploreWClass|CabinetWClass
4 J9 `, N1 D5 S# ^+ [ ; open ‘cmd’ in the current directory
[* F. D, G+ M6 @5 `* @ ;
" _% x! k0 z0 E3 u G1 l3 h' L #c::
+ V3 |4 F5 C( a- f% x! D OpenCmdInCurrent()
5 I7 L& |" E! w# s return7 e9 v1 `/ v5 j8 t$ }3 d
#IfWinActive& p- j6 u4 s2 _$ N
; Opens the command shell ‘cmd’ in the directory browsed in Explorer., t D/ ^8 |% a N! H
; Note: expecting to be run when the active window is Explorer.
+ D. n( x( q% F( T/ Q2 [/ h5 d& s- f ;7 C0 h+ s# m U% z
OpenCmdInCurrent()
2 c$ s( s$ M" u# q1 a3 Y {5 q2 _$ T' z: a' m( }& K
; This is required to get the full path of the file from the address bar
6 k% b4 z0 ]% i* E* c! ]9 c% m WinGetText, full_path, A
* @! o3 F, d, _, C: H ; Split on newline (`n)
( J! @* N; S6 s( X( \1 G StringSplit, word_array, full_path, `n
5 }% t6 D4 j3 k& u# K6 A$ {% T ; Take the first element from the array/ @ M' v# o, c, B; `4 ~) [
full_path = %word_array1%
! {, I3 g/ {; U y2 o/ [: m. q( G ; strip to bare address. s- h1 B4 K$ R; c) A
full_path := RegExReplace(full_path, “地址: “, “”)
2 t; b2 L; s3 a2 c9 g; Y ; Just in case – remove all carriage returns (`r)) l) x0 u4 s1 W7 w, t# }
StringReplace, full_path, full_path, `r, , all" Z8 G: b0 f: F$ M+ q4 M
IfInString full_path, \/ Z0 R+ _7 [: W- u& [% g* H
{- e( l% V5 v+ t/ Z
Run, cmd /K cd /D “%full_path%”
" O- |# n5 {% U* n2 r% p }
7 p8 S, h3 s. K6 _ g- t& u2 I else
" e* D% ~/ Q/ R& q/ X; K! n {+ x8 P* X3 p9 ^3 q& I$ R
Run, cmd /K cd /D “C:\ ”5 V1 Q+ t# Q4 ?2 C* c* [; Q
}
H: C w# L6 X7 m( { f }
* U& I: ]+ n. R- W' G 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# ]; i$ q/ U J, Q# _/ ^% g 这段小代码肯能有两个你需要修改的地方
; R2 M3 t+ x2 }$ d2 T% I 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
/ x) q/ `4 i4 \1 A4 ?% b 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 {# l6 W$ D/ _0 ~3 _ |