此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' F* [% s& L0 g i$ j" l 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 f- N% ]2 T9 p- ?+ t3 t 方式一:# @5 L. M5 P# X9 n6 }
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,) x& o1 S; { K; X `
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和$ \' L# [/ z; Y& R
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
, V# L& `- t! m* X* A! c" p1 M 方式二:
2 s) f, u7 l+ s" f* Z: ^+ Y/ t 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:+ B, Y; E: e f2 E; T
SetTitleMatchMode RegEx( _- L" v+ _4 I4 u
return8 b, ]' w8 S; H; ]4 O
; Stuff to do when Windows Explorer is open. _# @( b0 m+ H% u' G+ I* j
;' Y* D8 [0 U' @$ r2 c; [
#IfWinActive ahk_class ExploreWClass|CabinetWClass q1 |' b' R/ T3 p
; open ‘cmd’ in the current directory
: w9 L% I7 |3 _- D' ?6 W ;7 y7 u' Z" k6 Y: ~* }, A' J
#c::* Z" A* Y& ^( T0 I6 y" Y6 F" |
OpenCmdInCurrent()
( C1 D* h5 a( j' U3 \; z3 F$ }1 [3 ^ return# Y7 q9 @- k% O- ?8 Z, K
#IfWinActive8 k2 e+ H9 e; q7 T5 V1 r" `# d' U
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ C- n: T8 E* d# R6 m$ H: l
; Note: expecting to be run when the active window is Explorer.
J( ]5 k7 g& {7 c ;
% a. p5 H* {; r* p, r0 |9 R OpenCmdInCurrent()
1 f H) b p3 O" G# T7 H {
) Y0 J4 K# r, G; `. N# W$ a$ u ; This is required to get the full path of the file from the address bar
3 x0 ^- L# @5 |1 g3 W WinGetText, full_path, A
' @7 k) V1 _0 c/ r# l ; Split on newline (`n)" U, a: ?3 W, c, v: {3 A
StringSplit, word_array, full_path, `n
, X. \$ c7 V( c$ a# T* }/ O4 L ; Take the first element from the array
7 _; N) d+ |* @3 w. Z full_path = %word_array1%
& y, [# }& o/ q0 ? ; strip to bare address4 p$ T2 H4 E- R1 W
full_path := RegExReplace(full_path, “地址: “, “”)
5 j6 N) u: A9 h) K1 s2 g0 e" H& P7 w ; Just in case – remove all carriage returns (`r)+ N6 @* L( J h0 K/ b; T/ n
StringReplace, full_path, full_path, `r, , all
2 @1 i9 j0 l6 ]2 }) M$ ] IfInString full_path, \" Z7 {$ j, h) `2 a
{! L% j& j, B. Z* a4 e: X- X7 f$ `
Run, cmd /K cd /D “%full_path%”. U& l, v/ ^( y d2 t/ f& P
}4 D o9 `: |2 M* s; z' Z
else
$ |. P% e& u8 W+ q7 e* ]: _% K3 A6 M {/ J; a, S: |% ^. s' a
Run, cmd /K cd /D “C:\ ”
4 m5 h( N; M W. R }
, h8 k" o, X% S2 L* m# w }6 K' P5 N- h& i
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。8 Q& q, c! O% v% g7 A; X! h0 A" j2 N
这段小代码肯能有两个你需要修改的地方
$ E9 F: j0 ~5 v" W 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ q. Y1 }5 X0 [! A. w' w* E 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. R& J# w: s4 n |