此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, Q3 q' g& t& Z$ Z3 \4 Y1 A
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
' U( M, p# T4 q7 _2 k 方式一:1 u; d1 \6 J2 K. K: D C
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 H4 }" L2 D Z5 f% S) A
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. f, f2 e6 |; P9 m% r& Z8 n' W HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
# p' P% I- [1 I4 z4 `: P9 f1 a 方式二:
/ r6 Y8 Z5 h9 f# k5 T0 J 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) O& a+ Q! I! A1 R3 ~0 ~4 x SetTitleMatchMode RegEx
) ~# M/ W% k6 [ [ return
3 W8 c& a, x3 |5 x ; Stuff to do when Windows Explorer is open
( v( P: T5 M) e0 E ;
2 r( G2 Q! h+ D0 s1 i #IfWinActive ahk_class ExploreWClass|CabinetWClass
, n% z R0 R9 S/ @3 I( E0 V$ E+ k6 l ; open ‘cmd’ in the current directory- f( ?4 N) l: I( }: `* Q
;
2 K5 A3 u. d+ ^ #c::% `) B8 F9 K! G$ p( u' n
OpenCmdInCurrent()! h0 h6 y! l& S" t- p% g" P7 p
return2 |7 J+ l8 B$ H
#IfWinActive3 X: S- q! I# |; q% T2 j
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.. d0 j& K. x4 l3 f, o
; Note: expecting to be run when the active window is Explorer.
2 B. {; R; Q: Y% _: G: ~/ M ; g) n; i1 l {: o% {% k
OpenCmdInCurrent()/ t' {7 p* r, |' W# h4 h
{/ P y$ U- j F3 T2 f
; This is required to get the full path of the file from the address bar8 T, P ]: k' ^2 ^2 l! d, L, M
WinGetText, full_path, A9 C) [7 I( G- `$ y8 l
; Split on newline (`n)
% y! H; Z0 J9 o4 [8 L" j: v StringSplit, word_array, full_path, `n
( z: v, N. D8 `; o4 q K# a ; Take the first element from the array
7 `" j9 w/ s- z0 Z8 |" ] full_path = %word_array1%2 x) J$ h, s1 `! ]
; strip to bare address L y' r- }& E
full_path := RegExReplace(full_path, “地址: “, “”)
$ T& x: Z# o0 ^3 t$ |+ { ; Just in case – remove all carriage returns (`r)
* B* w$ |/ s) @: k5 g StringReplace, full_path, full_path, `r, , all
( O9 \; v, [* h5 y IfInString full_path, \
2 x# O0 U6 ~# ]4 Q- h8 `( g w {
) F8 Z6 r! ]! X+ { Run, cmd /K cd /D “%full_path%”
; W3 L+ H( Q1 [/ F @ }# ^" N+ G w" j; r
else
: k7 `% @9 y- H/ e, l: |7 x {9 M4 C8 }/ V. p7 S4 B
Run, cmd /K cd /D “C:\ ”
' d* }1 S: M+ m) x; q }
5 o2 `" F0 p3 P6 y0 Y7 c }
: _" T- b* J$ n0 s5 Q1 H 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: Q1 L; c1 q3 { 这段小代码肯能有两个你需要修改的地方1 N4 i- S2 ?( Y% P+ l/ j
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 t+ y& m* h/ | w, j1 f$ W% p6 `
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
+ @* S3 ]! r4 P' P, m; y5 o |