此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# q) x4 M& R4 X
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* I: s6 U1 `7 J, G, t) A+ L
方式一:
6 }5 |( P- s5 h6 Y4 c 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 u; [, O+ m' t( J5 O9 o9 e
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 R# [# z$ f3 y HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' i& ^+ t7 q+ b- l. X7 C 方式二:* |7 y$ N3 B) w: i
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:; ~* |) |8 Z2 s3 f
SetTitleMatchMode RegEx
3 x( r5 @& y& H return* K0 W. w: p. s- m( p& i
; Stuff to do when Windows Explorer is open; ~+ a( j8 c% w0 |
;
# l+ [: P0 w0 W8 t6 K, v #IfWinActive ahk_class ExploreWClass|CabinetWClass/ o) b) X) `# `8 {- Q5 K
; open ‘cmd’ in the current directory
7 Q1 P9 v7 X$ ~! B$ Y ;" G, [& M/ O8 J' l/ Y: ~" Z
#c::) D, c8 b2 o3 F8 Y6 E& [9 }- {
OpenCmdInCurrent(). v% R/ L2 F$ w+ B
return
, Q2 Z& u$ U5 Y #IfWinActive
( ~6 {' q; B* u6 y5 S ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.- {% O$ R$ ~4 j+ j
; Note: expecting to be run when the active window is Explorer.
, ^, @2 b/ p. W ;
7 z i i- n; S OpenCmdInCurrent()
9 G2 X# y7 P4 w+ V8 H! n: N {9 o/ b t7 \! Q* e( `
; This is required to get the full path of the file from the address bar1 }2 M" Z1 _" P" a
WinGetText, full_path, A
0 v" v8 N0 n( Y N0 Q/ F1 b ; Split on newline (`n)
; T# I3 T6 b/ o; j4 x8 h) B StringSplit, word_array, full_path, `n
, i+ {0 Z T4 ?" t+ {( E( e9 ^% s ; Take the first element from the array/ K5 r% O" w' {; O4 J+ B& S- j
full_path = %word_array1%
: Q* \- w. U( j% b# I# U6 e ; strip to bare address3 |! t! n2 z, E9 M
full_path := RegExReplace(full_path, “地址: “, “”)
( e( U ?8 u, h& X$ i) p9 Y ; Just in case – remove all carriage returns (`r)
% t8 D! h7 r- ~) N/ v% h v StringReplace, full_path, full_path, `r, , all$ c; H% x: S9 W4 E. I7 A) m
IfInString full_path, \
. E( B3 a& j$ ` {' Z8 z. p# t- V V
Run, cmd /K cd /D “%full_path%”/ r, y# {- v& d
}! F3 `# k! O5 f( U/ _/ q: J# ?6 I$ @
else5 O0 ?" E3 n9 ^+ u
{# ?8 O- D5 ~; s& W5 m; S9 v
Run, cmd /K cd /D “C:\ ”! ]" q$ [0 c; h7 ~
}2 h2 j. q- @9 R E& |
}
. N4 k9 @7 Z7 { 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 R( ]; ?2 R" C
这段小代码肯能有两个你需要修改的地方0 D) C! P9 _9 k3 ]
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
2 q; h; |1 j F. I 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “* a; T# M4 G8 ^ A ~) \3 _6 ~
|