此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。0 y5 z& t: a* l, E: G8 b# z: x }
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
" p( ^: U9 I+ a" [ [ 方式一:
: @' M5 B; f& v; [4 \ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 h3 n. L$ G, _* ^
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" b8 P+ Y4 O2 |
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。; G/ ?! O% A; J8 ~- ^. z! J
方式二:
6 ?/ K# p/ K: c3 D 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* P7 n- A$ q3 j5 _ SetTitleMatchMode RegEx
2 J8 b3 p2 f; y( y S; F) r: s return2 `8 k* u. U/ d. u
; Stuff to do when Windows Explorer is open t- w6 Y* T" F2 a% G& R
;
" W* Y6 _7 J/ ~! J6 L" k5 _ #IfWinActive ahk_class ExploreWClass|CabinetWClass7 V: t1 [, r& C" X6 x4 {# A% t
; open ‘cmd’ in the current directory
4 U2 \+ D' G" Q' m! y# X, ~ ;
0 `& W* H5 e3 ~1 @ #c::( D8 x) H6 ]8 c
OpenCmdInCurrent()3 U9 B6 _% w# `7 z0 B* a3 J8 N6 ?( Q
return
\: _, J! a8 h9 r+ l* W #IfWinActive
. s' }, X6 j0 P8 _ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) J9 a! U J& ` ; Note: expecting to be run when the active window is Explorer.
; Q, T( ^! t5 B/ p ;4 b( T1 C2 T" Q: k
OpenCmdInCurrent()7 a* D. q7 k$ o
{
$ s+ ?8 `! ` S/ B ; This is required to get the full path of the file from the address bar
+ J; I* T( x& v, D+ W1 Z WinGetText, full_path, A
9 R( c: ]7 z( B- s, d: } ; Split on newline (`n)
$ \: ^; D3 o7 [$ Q1 ]( u+ s StringSplit, word_array, full_path, `n" M; ]7 G) y* {- Z( g) C& n" Y6 G
; Take the first element from the array" c! n, f# \3 P5 X. p
full_path = %word_array1%$ u0 _6 y8 w) g% L
; strip to bare address8 n$ V: P% f. e* D! Z0 m
full_path := RegExReplace(full_path, “地址: “, “”): G; P6 W% b0 E7 m* B5 J
; Just in case – remove all carriage returns (`r)& Z- j1 X' |! a" I9 c5 E
StringReplace, full_path, full_path, `r, , all
4 ~8 V* C+ s0 w9 H+ ~( Y+ u$ i IfInString full_path, \
+ T* L9 e; S. t) x {
8 _3 w- }& O* _ Run, cmd /K cd /D “%full_path%”7 s( q9 _2 A; G! \& I9 P1 Q
}5 z- @1 ^: G/ ]) J& ]1 N8 M7 `( U
else
( x3 l/ O9 X6 B {
, ~' S' _- x9 x2 \- l Run, cmd /K cd /D “C:\ ”
6 E/ a5 V4 E1 ^$ Z# w- n7 F }
5 S+ Y8 i" s! Z8 g" P4 ]7 ]7 ^1 U }
' ?7 ^1 V; b3 g z7 g/ \& T 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
h, y" o% @$ W; }8 ] 这段小代码肯能有两个你需要修改的地方
R5 }- u1 n/ E( u8 o" i+ a 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键8 x A; F" M7 B! `6 R
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! B" i! y+ ^4 y8 h; v7 e2 O N9 E% v
|