此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
9 y# l: D# P+ {% q ?9 G: _3 C* a% W$ M 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 A3 x4 y( X F' \6 p
方式一:
2 ^. _$ S0 `+ X1 z D 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,! {$ M# L! k) ^* m9 X8 e( b7 e
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) P2 f, f: U' X& u H7 C
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" Q+ c j; p, k! S9 X! B4 G2 | 方式二:
& E! ^/ y0 [3 [' D- ~ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" d5 `4 W& u$ m& o SetTitleMatchMode RegEx
5 Z R9 E; O0 ^. I( H* Q- o$ \ return
+ @" t3 E0 @. N8 N! R- N ; Stuff to do when Windows Explorer is open
, D# c; L, b j! x' h1 ~" R, }( l- W ;+ b- G% F8 c9 i& ^3 b8 ^
#IfWinActive ahk_class ExploreWClass|CabinetWClass
; H: ]1 v/ V* ~: E ; open ‘cmd’ in the current directory
% [0 A$ r8 i" t( C3 g* R ;
+ f% Q+ z* c! G- s #c::2 Z/ H7 M, f1 n% ~. K8 N3 V3 O2 N
OpenCmdInCurrent()
, G6 M9 U' g% s* r4 S return
$ {- _3 ^! `+ j: s9 W #IfWinActive$ ?1 e: `6 c: E, Y7 @; r4 Q' e
; Opens the command shell ‘cmd’ in the directory browsed in Explorer. Y, @3 t# e$ }& W; t* w+ ~
; Note: expecting to be run when the active window is Explorer.0 q, m! W2 L! e
;" l2 Y9 @8 G r
OpenCmdInCurrent(); D- t+ V K0 U! ~' v/ b
{) t1 Q) Y, R7 ^
; This is required to get the full path of the file from the address bar
& Y7 e# `4 Z) O1 h8 V0 @ WinGetText, full_path, A' Z4 w# j) g/ c1 B2 e& j
; Split on newline (`n)
3 R6 C: J* ?. r% d1 x6 n StringSplit, word_array, full_path, `n1 ], A2 @8 [6 i! q' f8 P
; Take the first element from the array4 [0 v! g$ ^/ O# Y2 Z
full_path = %word_array1%% o8 b. t- M3 F
; strip to bare address
$ o. i: B0 H3 j! ?% x. n full_path := RegExReplace(full_path, “地址: “, “”)9 U2 i* q- Y! b/ X, }6 Q) F4 u
; Just in case – remove all carriage returns (`r)
+ S Z# E: `- i! l4 t5 S V StringReplace, full_path, full_path, `r, , all0 w4 l5 I2 I* R5 J! e. m
IfInString full_path, \
- t1 M) s* N* a- v Z0 Y6 M {8 b8 E: o4 A6 O B3 P# f4 {
Run, cmd /K cd /D “%full_path%”. F: |+ P( R* |0 }
}9 E4 h8 x6 y5 ]- w
else
, J! Y% _% r7 g: x {5 s, J" R$ F5 r# ?! ^0 f
Run, cmd /K cd /D “C:\ ”+ X- f9 X3 {1 c3 N# ]
}
9 W8 F5 k, n; I) h, l7 b }
1 Q4 Z/ |' m5 S9 V- J0 F+ Y 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 _' k! i0 @' {
这段小代码肯能有两个你需要修改的地方
1 J. f9 y+ ]; j9 _% e l2 J 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键4 W3 P2 v: k! V# I
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 G6 c, d9 f- f# X |