此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, s+ i2 I4 H; h$ C. i( i( G3 U
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 A0 a1 f7 I7 L, L s5 B( ~
方式一:' L% l- d3 Y" v; c2 H
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, @% {7 r- v0 E, y7 X
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ d9 ~' i8 O* s+ h
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 }3 J% G" P s5 R) _ 方式二:
1 @; S( T0 U# I" W5 ^ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:8 Q6 |# Q% N4 @# d2 q7 X
SetTitleMatchMode RegEx* R) o, C" h# V6 x4 Y
return
" T2 g- S* ^" S8 h ; Stuff to do when Windows Explorer is open
9 ~4 A' T% l" R: y* g5 u& G ;# \. ^/ P2 e; y9 U- U5 E
#IfWinActive ahk_class ExploreWClass|CabinetWClass5 @7 c7 }! _) c! ~& N' Y0 G S
; open ‘cmd’ in the current directory
3 e& F/ G/ ~# Q- U% E# D ;
; W R9 q& I# p; M5 H #c::
' y9 [9 Q$ K! @+ b! } OpenCmdInCurrent()
6 d2 T' {# k4 B8 U! j1 s$ i return* m3 o* k' D& w8 Y
#IfWinActive; m9 W* A3 z* g2 W9 `
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 n7 p, O( G. @8 \ ; Note: expecting to be run when the active window is Explorer.: j9 r- K1 h& g3 R5 H R
;
9 Q9 k9 z& _- [9 E, D. N OpenCmdInCurrent()
! H3 n5 O: { g, [5 a {
. o3 ^3 \) I# ^4 y* j ; This is required to get the full path of the file from the address bar! h& Z& M# L; P) ]: H$ }6 S
WinGetText, full_path, A( s% o* Y9 M) l! R a9 U
; Split on newline (`n)( ~- z1 A* i: B ^, S* z3 j
StringSplit, word_array, full_path, `n1 ^6 g+ |) u- m" X
; Take the first element from the array
& A# Q" S/ _; P/ ?: ^$ p full_path = %word_array1%
/ r' |0 u3 M" X( Q% G, |4 M9 X9 V ; strip to bare address4 s2 A" {6 l# r1 u2 N
full_path := RegExReplace(full_path, “地址: “, “”)& ~! L5 d4 J" w w" Y2 n
; Just in case – remove all carriage returns (`r)
% Z+ B- g- h3 M7 q+ x StringReplace, full_path, full_path, `r, , all+ _* k+ z, C/ A7 s8 L& ?
IfInString full_path, \
D* i. i/ V# ]. L8 k {
+ ~* Y# k7 L& M/ N% E9 B Run, cmd /K cd /D “%full_path%”# l& L2 R1 u! m5 J8 _! V. U8 C
}
, _8 h- h0 Y( i) ]( L5 b) \ else
% c" Y2 I# H5 D# A' s {1 K) b( }- T6 _# Z l
Run, cmd /K cd /D “C:\ ”3 Y% @* Z' |: e
}
9 K, Y' f% N( [; B# v }
% ]7 W/ i a3 U 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. d6 o! }! Q! ^8 r" @ 这段小代码肯能有两个你需要修改的地方
. ~7 j" ]* _/ L) n: D" W 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 o' N. U8 f$ u) N 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 I G2 j: V1 b: { |