此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
. P4 c4 b- p3 q" c, B+ q8 Z+ N$ `3 I 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。# l6 L; a2 U u' `# o, v" _2 r
方式一:
: |9 R- ^0 o" C/ y% z3 F$ M 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
8 U6 R: T" k& d" v 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 i S- L! S2 g
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 s7 s% F; @/ R. K' m
方式二:! n' V7 H4 A3 I) B, b
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ d" Y, T0 J. y1 O8 G SetTitleMatchMode RegEx- d# U1 K; z* o6 D: J* n% E" x9 y8 H
return2 n( Q! p) I5 \
; Stuff to do when Windows Explorer is open( v( Z* t" W/ d
;2 f: S- \- V5 p* Z
#IfWinActive ahk_class ExploreWClass|CabinetWClass
- y, M) c9 `+ W+ Y4 w1 d ; open ‘cmd’ in the current directory
4 N+ r9 h/ Q; A7 O* I! `' Z9 _ ;. ?4 F" W8 r3 L" ]4 b U0 Q; `
#c::
& b& N8 K! I' @3 c8 z6 D7 R OpenCmdInCurrent()
. m# K7 G d9 Q# m return# ?5 K0 T0 r8 b" F
#IfWinActive2 I2 W+ }; l; p' \- I
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 c: c0 S5 N. K; J" Y. y L) u
; Note: expecting to be run when the active window is Explorer.0 ~3 K" L) _$ B
;! S: ~1 l0 l) t9 \$ o" b
OpenCmdInCurrent()
8 o8 u- m: V! T z4 | {, j* v' F* O4 J3 N3 r* {
; This is required to get the full path of the file from the address bar" }( Z9 x$ i( V0 \$ j3 x2 P2 m! r
WinGetText, full_path, A
$ t8 L3 `2 J% ]2 {1 Y4 N7 K ; Split on newline (`n)
% Z N# B. G9 n6 Y. x5 u: z StringSplit, word_array, full_path, `n: Y1 ~. Y& a, k8 }1 r
; Take the first element from the array
8 e7 }& W8 o) `3 b( l/ y1 g full_path = %word_array1%& M+ k) q4 o# q' D
; strip to bare address
3 F3 Q+ [4 p+ c! M full_path := RegExReplace(full_path, “地址: “, “”)
2 F% N8 {" U7 ^+ b( E% Q ; Just in case – remove all carriage returns (`r)) i! e x' j/ l6 j( w, U& R
StringReplace, full_path, full_path, `r, , all
5 T+ G0 E& \9 I& g5 ^8 A5 }8 \" o IfInString full_path, \
( W3 p7 D% Q- N {5 l2 V2 V, ?3 P; Q
Run, cmd /K cd /D “%full_path%”
. O/ M# c* Y! m% p6 w. X }
5 H7 `4 G: S+ R; W else2 K2 K* r6 s ]2 x- q5 H0 D
{
( L0 C# J8 \9 [& b9 }6 o: m Run, cmd /K cd /D “C:\ ”
2 E ]2 q: |' @6 h }
) R4 I* F/ ]* S% p6 _* s) T6 ]7 F }
( L- J8 J' O; e6 j6 O9 O 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: [9 Z. e, J0 \$ s
这段小代码肯能有两个你需要修改的地方
# Z, ]: |, |3 |5 E 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 L! T1 B( A8 t8 Q# ^ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) \$ i7 Z. p X8 e |