此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 w ^3 \5 L, C8 }
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 j5 _0 e0 s" g; z5 A# ~
方式一:
: n/ B7 ~' }$ A' t 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
D% s7 d8 z L' m+ }0 S! V) _ V 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: N( {, \# [3 l! p2 f
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
1 y$ \5 _3 L3 M8 i 方式二:
/ X8 T" C: M# `" p" L 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! q0 u1 m/ Y7 ^
SetTitleMatchMode RegEx9 O$ c/ V* x$ y" N; F6 q+ f. a
return# K" E) C. J' [
; Stuff to do when Windows Explorer is open
6 X/ v& i$ L3 I) Y7 E/ Q4 i1 d ;% }! p' ?3 L |3 C9 E, \
#IfWinActive ahk_class ExploreWClass|CabinetWClass) ]5 U2 q% w9 w" g! ?- c, q
; open ‘cmd’ in the current directory
" Y8 ^+ W! {( @! f: K2 i* C ;
5 g# W. M1 p5 @4 b2 Q! Y! ^1 A #c::
- S1 j- d: P( @ OpenCmdInCurrent()5 G* S% t6 f3 W2 v
return5 R' e, m0 \( `" ~+ @$ X0 I
#IfWinActive
5 X/ p9 G7 R: R. N% n ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) C' j# n. x2 D5 N* x0 d# d ; Note: expecting to be run when the active window is Explorer.
* a. c: Y5 _) w& I& i8 E2 f ;
8 z, W( X; a! O+ k4 |1 W% J3 R OpenCmdInCurrent()
0 H+ E7 {. G6 d' B/ j" G! B" r$ V {
' ?9 C: J- B2 K ; This is required to get the full path of the file from the address bar
4 Q+ N" g- r9 s3 T WinGetText, full_path, A
; P. x+ Y4 G* z8 s/ |5 M7 ~( ]7 P ; Split on newline (`n)0 m2 e- T7 X) Y
StringSplit, word_array, full_path, `n
- H b3 W7 J4 v ; Take the first element from the array3 L" a' q4 t- a5 Q) ~4 p
full_path = %word_array1%
( q: ^7 W# a8 y ; strip to bare address0 o( h1 r$ ]7 p" \- g
full_path := RegExReplace(full_path, “地址: “, “”)- L$ L/ a% k8 `7 Z
; Just in case – remove all carriage returns (`r)
3 d) _# b" S8 I1 n" N% I( D1 ]# L StringReplace, full_path, full_path, `r, , all
7 b0 Q- R% p/ f3 V3 x7 R/ D, T2 y IfInString full_path, \
. J' D8 v4 k3 ?9 l- H; J/ N {9 |) y. |( V0 I, f2 X* j
Run, cmd /K cd /D “%full_path%”+ I& I2 c! D. j3 n x+ c- ?
}
' p2 O+ Y5 T7 j% s' O+ A else: N1 V7 j, `' Z5 a4 z/ F$ n u
{' h3 L; p1 o& \7 t. a
Run, cmd /K cd /D “C:\ ”
# a5 E. q t3 {2 x1 {5 G& i, R }
5 X! Z- |. Z* ]* e9 W3 b0 x# K }
4 S7 z% P; W/ E9 h% }/ e 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。, k9 Q" j( z% `# A: E
这段小代码肯能有两个你需要修改的地方* X/ s3 U3 b9 d% |5 l5 p
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键4 _' W h5 Y9 y( P4 M
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* F' x4 w) u7 L$ D |