此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ ~* n' \1 _/ f3 H
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。+ q/ {% r# g; U9 e( t' Y1 a
方式一:
. t0 R2 b0 H9 {3 B9 @- ] 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, t8 H6 D) \0 ~ \" _9 ~" M) o/ ~
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
% Z, X% d7 h/ z% {1 K HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 H, G4 |( f! m7 ? 方式二:
# Z( f/ V1 [$ x$ ?) a5 z2 H* S2 G- b 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 J+ z! i+ F/ M
SetTitleMatchMode RegEx, M$ b5 F% y% G1 i, B* P5 \6 Z
return$ T& v; v& ^' f# N
; Stuff to do when Windows Explorer is open
% `. j# G3 c' z+ W$ j r ;
1 k/ U& {+ {2 L7 `' l4 e7 | #IfWinActive ahk_class ExploreWClass|CabinetWClass
% f; ~3 W# G" [0 f8 o ; open ‘cmd’ in the current directory
8 P- q1 f# @5 N/ d ;) J9 P9 }: F- E! A ~
#c::
3 _' A5 p: I$ \; E OpenCmdInCurrent()1 y1 L; V# f& d0 j
return5 k0 U9 M3 B8 V. q. G
#IfWinActive
4 L k# h; ?3 f n0 D* s. R2 N ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( z( l! D! @ o. M# V ; Note: expecting to be run when the active window is Explorer.
\& r0 Z% D" B: L# i/ d ;
7 a- e) b; N! q OpenCmdInCurrent()7 P9 E9 _$ e1 e( O8 ~, i" @
{
7 K3 }% c: G% A/ h. V( ? ; This is required to get the full path of the file from the address bar
2 b2 w3 \2 H7 P7 O( ? WinGetText, full_path, A
& S* ~; m7 M a$ u$ @ ; Split on newline (`n)3 r; E3 `" i0 s* u
StringSplit, word_array, full_path, `n6 S; M+ m8 I) [1 s5 f
; Take the first element from the array" Z7 p' K' m/ }5 H. b: d
full_path = %word_array1%
* s* i% R- ?1 |3 u* f5 p ; strip to bare address
2 g# V4 b( O, A* m* V, E" H1 G full_path := RegExReplace(full_path, “地址: “, “”)
! y6 f) J' K0 Y0 A4 L ; Just in case – remove all carriage returns (`r)7 P, z4 ^2 n# ]7 d6 K
StringReplace, full_path, full_path, `r, , all- h' m2 Z2 U' d4 d# l3 d+ m; p
IfInString full_path, \" O t0 x$ P- K, a& ?
{- s6 m3 m* `8 I1 _$ x3 U
Run, cmd /K cd /D “%full_path%” W0 F, A3 ~* {% t& \( Y" j5 i
}% [5 X4 j |+ N2 y
else+ I# S3 v. i, f( Q
{
0 D8 L. y7 p& w/ q9 Y& S5 E2 v Run, cmd /K cd /D “C:\ ”
/ ?* k; t$ t/ O9 j* J2 g0 s }
& u6 w7 M1 i. r4 A7 D }* z4 e L$ p" J9 e
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 K: m2 N% t0 S! S' H) C) X/ @ 这段小代码肯能有两个你需要修改的地方
5 T" r3 d2 H. \* S% G8 X" e6 V1 Z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 u' K3 ?- V- S; g) ^ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) {7 P a: U4 j) g3 N5 b |