此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
: u* n4 e8 y. g% N 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 g/ t( c X( m, r9 m
方式一:
+ B( K- U3 f0 N3 |& F& l; s 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- d& B& w8 z9 ? l4 [ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) |: u# [ I7 B ?- j" s0 m
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! t. w4 ?. A- Y/ Y0 q
方式二:
: e. A& ^4 H6 i" i0 L$ @ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& g6 L& @# x, c SetTitleMatchMode RegEx
7 W( v0 y$ W" x$ s return: G! |% A1 t" v* U6 R2 w$ K
; Stuff to do when Windows Explorer is open
' f* W2 R; H6 x& o ;
0 N& N2 ?' ^9 _; ~9 F S #IfWinActive ahk_class ExploreWClass|CabinetWClass
! y( n! O: l2 s6 x* h. M' I ; open ‘cmd’ in the current directory
?' r; F# D# O+ n; d ;
& O; W' x" ?4 D7 O, V0 w #c::2 @! T& S: n/ }/ j# F1 T
OpenCmdInCurrent()
4 d; m2 m, A6 `2 A return$ e+ |) F9 f$ W' _: m
#IfWinActive7 \' m+ H% T9 M& ?
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 ^7 x7 v2 _3 g( e- h2 |6 V ; Note: expecting to be run when the active window is Explorer.
& W1 p# y/ u& W0 S! x* v ;2 G( \7 p2 d8 n: K. W2 \
OpenCmdInCurrent()
) n, |6 F; q& z9 f* x6 [. ? {- C# a, W% s. Q: B1 X5 t
; This is required to get the full path of the file from the address bar& r) c p" e$ K3 ]$ C
WinGetText, full_path, A
1 X# {9 G& Z( g1 w) @# C ; Split on newline (`n)# |8 S! k8 G5 }" S! l5 M
StringSplit, word_array, full_path, `n4 Q: q# g& l4 F0 R* M) e* R
; Take the first element from the array$ w1 v9 E$ C; A
full_path = %word_array1%
! n' m' Z# S9 J4 j: Y" T ; strip to bare address
7 [, x) Y; @- F3 d* h" ? full_path := RegExReplace(full_path, “地址: “, “”)
( p$ Y2 j; @- \0 P4 Y( U- n9 g ; Just in case – remove all carriage returns (`r)- a1 T0 Z8 m1 V* y' c4 }
StringReplace, full_path, full_path, `r, , all1 d1 Z# n% p8 C( G" J& x
IfInString full_path, \1 K+ A! c" R# I
{9 _8 ^8 ?4 z! i% l6 ^/ I4 a
Run, cmd /K cd /D “%full_path%”! c+ ~% U7 J& z) \
}$ }; B) d7 B1 G! _5 a7 m8 L1 k) x
else
) G! p: ^/ t2 Y {
" o0 i( c( o( j0 h- a Run, cmd /K cd /D “C:\ ”; [7 ^/ _8 ?' k: z O" u4 I5 f
}5 x2 e$ Q5 s9 h* l g7 E/ B. ^
}
6 `+ [0 G1 n! K 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
/ b) c& ^( H8 A, O 这段小代码肯能有两个你需要修改的地方- T6 {( K9 \5 e" Z7 ]
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 j2 ]( ] G# R/ I! ~, ]9 C 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! L3 U1 ]9 d# X- V5 q+ L
|