此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# y2 _6 l! W0 l" V+ k. k4 o5 p
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& y+ X" n( ^4 e0 f7 d 方式一:- T' k( I1 Q# z" G, d* G
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,3 W8 ^2 b! j8 j; O; E! w" S6 A7 W
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
+ Y- _) f4 Q. D* V5 D HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 r" Q$ O8 r5 t; I/ i8 Y
方式二:
' f* U! k9 ^1 U r: b# M0 x 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
3 v; r' N6 _6 D+ N9 V SetTitleMatchMode RegEx3 A/ |1 r/ t1 c; q( S% t" N6 w6 h
return
( S: |+ l' z( ?9 d# G5 W3 x+ q5 \% w# ^ ; Stuff to do when Windows Explorer is open4 n8 [1 y* j- R# u' T- M
;0 D$ f" i5 m+ c0 g* ?
#IfWinActive ahk_class ExploreWClass|CabinetWClass
, u! H: _& ^8 Z2 H ; open ‘cmd’ in the current directory
# M$ @; y! ~, k0 z# j8 E ;3 H/ S A! H, L6 |' J/ w
#c::0 D, ]# r: N- N8 t5 q% ]# _: {
OpenCmdInCurrent()
/ x4 c) X$ {" m9 k* @5 `6 t7 o return, b) i# | v! {4 q7 |5 U1 D. R: h0 R8 u
#IfWinActive; h2 ~+ N: y) m3 o5 l% z
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 K$ v- }' _6 T* e# V8 S) L
; Note: expecting to be run when the active window is Explorer.
2 Y! T' N* p9 a$ B1 x, Q' E( u& z ;
$ e4 ]! A! e2 a0 i3 m( V/ I OpenCmdInCurrent()# N% V4 K! n* m/ _' Y& \ ^
{0 C5 I) Q4 _" v) h2 z( M
; This is required to get the full path of the file from the address bar1 L* l* Y# Z& s5 p2 D
WinGetText, full_path, A
; N( T# T& _4 M; m' r% n ; Split on newline (`n); T1 F2 ]$ ^( C$ I8 p
StringSplit, word_array, full_path, `n, B- m1 S; y- M5 @4 P. y
; Take the first element from the array
- S, t/ c$ y' g" e0 O l' o" P+ p full_path = %word_array1%% u9 R5 W ~ d5 [: \
; strip to bare address2 C9 Z3 Y( l* o. T+ B9 h& l! f r# @" @
full_path := RegExReplace(full_path, “地址: “, “”)
0 b" }5 _7 v$ m0 x8 d ; Just in case – remove all carriage returns (`r)
7 b( w8 c" D" F- ~, g, L3 W: j StringReplace, full_path, full_path, `r, , all& e2 e9 h: d2 G- B+ s: m
IfInString full_path, \3 D, @/ l6 ?' C. k7 @! o
{5 q5 O G- c" b) r0 `
Run, cmd /K cd /D “%full_path%”
+ R" n9 k; v/ ]- g9 L' u }
! C1 V- H P6 K else0 G2 D) b$ A" S9 _
{
7 H& @- D/ r4 c, G! ~, d Run, cmd /K cd /D “C:\ ”
: Y' Q- y2 y4 P# {) A: n0 e }
/ M) E A' s- k7 f7 f }
9 A( N; _* u- ~- \2 v5 ]1 N 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* Y, |5 H3 K' ]/ I, w9 O$ {
这段小代码肯能有两个你需要修改的地方* R3 J% l+ e% {1 A; w% I
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. t8 M; B) j) i& M3 X! l 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
, [$ ~$ r3 v* Q8 g |