此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- K8 M; ?3 `' h# l- d8 L 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
. U7 v* a! T- j$ c2 E. E3 L& M# R 方式一:. d; g; k: ^7 w! w
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 q8 g9 S5 y" Q 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和1 V1 q5 |8 V0 r/ T
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。3 L1 y, ]4 V9 n1 b5 [& Y) A: S
方式二:
+ I g9 i4 ~' [7 h2 X# F! @' Z7 J 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
3 ]+ v! l- q' A2 ^7 G7 [4 }; z SetTitleMatchMode RegEx5 w$ A1 n. P, Y+ G3 U
return2 |6 s# S( X7 e: k! z4 U1 W/ v) h
; Stuff to do when Windows Explorer is open/ \+ K B9 I( p5 |) A
;/ ^6 v+ K6 @" Z: \0 |* F( K9 ~
#IfWinActive ahk_class ExploreWClass|CabinetWClass. O$ V" G' Y! B: _
; open ‘cmd’ in the current directory" k% t8 }+ H1 c& O' m
;
8 r0 k; }! y7 w" z! k4 f #c::
5 P3 {/ b* I" b( n- [" E: U OpenCmdInCurrent()
0 d2 u* N7 q2 d) ^- |& ~* L) k9 E, @ return" P! q: r2 @5 I, N) _( o
#IfWinActive0 F. h& L' m X5 h
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
8 W' m5 q4 f$ y+ v3 T# A3 I2 m/ X ; Note: expecting to be run when the active window is Explorer.
( K2 R2 v. t$ I$ {! R# ^* O p3 I ;
' m- a! b& u6 {, X, ^6 J: u0 J9 H" @ OpenCmdInCurrent()% M9 Y: A7 f. i
{( S2 ]4 D0 \+ G; ~- `
; This is required to get the full path of the file from the address bar
; N; S" C5 |6 \7 d5 e' K WinGetText, full_path, A
$ ^ j l4 D& L; R* j2 P9 q ; Split on newline (`n)
c5 W- d) o% ?3 w" B StringSplit, word_array, full_path, `n6 m: F3 a6 m4 n" `' I. G9 D
; Take the first element from the array' [8 ]3 [2 p W3 Q" I
full_path = %word_array1%3 [- @( i- I2 @& T% L. h) G' N
; strip to bare address7 b* a3 p5 h- }' _7 ^
full_path := RegExReplace(full_path, “地址: “, “”)
0 B/ S7 N/ @+ S9 K ; Just in case – remove all carriage returns (`r). a4 V/ q1 y' Z: \9 m# {+ _: a
StringReplace, full_path, full_path, `r, , all: R- q6 H& A0 k) v
IfInString full_path, \5 i( B. H9 f H$ z; i8 y3 j6 s8 ^
{
& X% r& f' `0 V( {# } Run, cmd /K cd /D “%full_path%”
3 Y+ z2 L: W3 X2 M/ v9 \6 m }1 w4 a% {; e, N9 e1 Q5 K. \
else
% i( r. f/ Z' g* z* o; x' y; I {
% V, _* j7 k: v( {( R2 H( X Run, cmd /K cd /D “C:\ ”9 L& }7 X% d U& ~5 S) r! z
}. c! P) H1 O* u. Z
}
- `: P; f! r2 Z4 p9 S 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
6 H+ s8 M: T, I2 I2 W4 H* g- W 这段小代码肯能有两个你需要修改的地方
6 P/ k3 M: D* W7 Q) N* H 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( C. M* A1 \# E `
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. M& M7 j$ Y5 u0 o ~ |