此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ Q# h9 E* M, K: e- B% ^ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。' {0 G. K/ w! _
方式一:
3 {( S- y1 N* b# C( X) k+ u7 D h3 Z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 p1 C3 S- i! D f" v/ X
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 U5 ?9 r" d. O" T1 }1 D HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 t B, O% Z( l' _ 方式二:% v, ]) y, H# {' n: k
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 t8 K1 l5 b% R# c% D SetTitleMatchMode RegEx! A7 Y* |+ D4 }2 m
return
( \! h. h' m- s% c ; Stuff to do when Windows Explorer is open; G/ ^4 ]4 D- R% {/ @4 E
; Q, R& s# p3 n, i
#IfWinActive ahk_class ExploreWClass|CabinetWClass
1 W$ V. H( l1 H2 E& c. b, v' \# ] ; open ‘cmd’ in the current directory2 g4 N& R: Z* e7 A) ^
;7 D/ K, l- _$ E8 c0 Z) i: r6 {
#c::# }8 {2 D& g R& V
OpenCmdInCurrent()
) T8 @/ ]* B: J. |; I: C8 u return) s3 r. K. i; Y; s2 N3 Q7 T
#IfWinActive7 l0 t- N7 m, D8 R; p3 @; r
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 O+ h$ ~* Q% I+ ? ; Note: expecting to be run when the active window is Explorer.) M1 L4 s1 a/ G* e/ F1 [- `
;' F) o6 n( g3 ~4 U R2 A2 A
OpenCmdInCurrent()
3 M; ?5 i8 [" b1 w {; g1 K8 T0 M3 b+ s$ S
; This is required to get the full path of the file from the address bar
/ m- p; ^0 m1 y7 ?2 f1 m WinGetText, full_path, A, I, @$ m+ ~. d# u( G
; Split on newline (`n)
% R. {' @6 O3 C X/ t/ Z StringSplit, word_array, full_path, `n
7 K; i6 }) d: h7 z8 ] ; Take the first element from the array
$ r& G5 G% ]$ {) m full_path = %word_array1%
3 [1 N/ J$ C1 E* G5 M# d3 u ; strip to bare address
1 C$ B9 w" k# [7 U full_path := RegExReplace(full_path, “地址: “, “”)5 ~( D& O( |0 {. ~% K# R2 ]
; Just in case – remove all carriage returns (`r)1 ~7 m: y! L2 }+ i- |3 k
StringReplace, full_path, full_path, `r, , all
" X8 {+ }' P6 P, M1 J6 t IfInString full_path, \
: y8 U. O7 I" m% H1 L {9 V" X# W2 r" _8 |, x; Q6 l# H
Run, cmd /K cd /D “%full_path%”) L& U% q6 s. ]# v+ a P* e
}# s- |. N# I* o4 J9 k
else4 y1 l9 x8 f. r' V2 D
{
3 F, e$ y1 E# i. F' a$ c Run, cmd /K cd /D “C:\ ”
5 V; L1 b0 W4 C9 W, p) `. v) O }
2 H5 v; }6 j1 y }& R+ l4 m' E' m! h S$ `
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 m7 L$ Q% d. c9 [
这段小代码肯能有两个你需要修改的地方. x( u/ A# u) ?6 `; O9 A
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键, N# ~! J3 t2 B# M$ J3 C9 A
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
6 t: E: M1 ^4 G$ L! c) d4 | |