此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 q; q( D' g2 _& b W! n+ a- k1 k% g
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 N7 L/ T$ w* D. d8 P b( N
方式一:
. Y; G. n& T, [. Y) u0 K& R 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,0 U) V+ {" z$ p+ N8 z; b
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 S; n% l5 B4 X; S5 W9 g4 @
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
1 `( q) s5 l9 B0 _- W7 v. n \ 方式二:
# V. ~7 U. M: ~3 r e 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
% Q) O" l* K @4 _6 y SetTitleMatchMode RegEx
9 ]" _ \3 J5 D- V0 Z return: w1 L& S7 P `- ?$ P% a* T
; Stuff to do when Windows Explorer is open- n0 C. Y; v0 ~4 M
;
, \0 |' a9 D! h2 ~4 [6 J, p4 d #IfWinActive ahk_class ExploreWClass|CabinetWClass
8 m- b9 _9 I7 N8 `7 J5 \( V ; open ‘cmd’ in the current directory
4 k* l- e- y: f* P ;
9 X- i3 H0 r/ C: U #c::
" B- m# H! l' h2 i. J& H OpenCmdInCurrent()" d! N# O( j1 \5 u
return
: Z" C" ~. H& O2 x #IfWinActive
; f2 c+ X& o' a) l# r4 ? ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 v$ Q! G3 K6 R' D/ x. v
; Note: expecting to be run when the active window is Explorer.
- [# _& k2 L2 Q- @6 K ;
+ X, `, j! S2 W9 ^) M1 c% V" _ OpenCmdInCurrent()& ?$ P$ t2 _6 ^5 r: l# Z
{
2 k/ I: {" Y: s W ; This is required to get the full path of the file from the address bar
! V4 g" {- }8 K2 f8 r/ | WinGetText, full_path, A
5 Y0 ~3 S3 [7 Y* i7 |( \ ; Split on newline (`n)* }4 q( d8 u1 n5 a# S7 g4 M
StringSplit, word_array, full_path, `n/ E7 G9 n; }, N, s
; Take the first element from the array
: b K& {7 m3 l" d full_path = %word_array1%
- M, U5 W2 v+ {+ z5 \ ; strip to bare address8 I8 c7 c0 [/ E# F- T0 {* A5 |
full_path := RegExReplace(full_path, “地址: “, “”)+ P& H u/ ^& _6 q
; Just in case – remove all carriage returns (`r)
% L; Q0 J+ J: L r StringReplace, full_path, full_path, `r, , all5 d& o5 h9 v( g4 C& z4 F4 d$ B
IfInString full_path, \) V9 o/ S A* X W+ `7 g
{
! U: k9 r) L; `3 o4 r4 u+ i1 [4 X Run, cmd /K cd /D “%full_path%”
0 K% r; O! P, t! c0 }5 P- [ }
: s# v7 N% ^7 Z2 c& _) j) A, g; F else" G$ h! {: \3 i9 \& M2 t: O
{( G5 q( Y4 X- _) G3 b4 f6 s- Q
Run, cmd /K cd /D “C:\ ”' ?) L7 @) `5 |- S" ^+ u+ J4 d/ e
}9 p2 b& J0 D+ H! H- Y2 ]
}
/ T# `3 a4 Y9 A/ ^ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
% B: s; p# {$ \9 [ 这段小代码肯能有两个你需要修改的地方
' x- U- p7 e7 F& n$ { 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- D- M* ~5 o8 p& ^3 ]$ `% _
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: D# m( x$ C+ F& x3 M! q
|