此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
# O$ N& b/ F! @/ w+ `1 g9 n. ^ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 ]& ` y9 W1 K _: R( D# {/ T5 A 方式一:
7 o6 k1 W+ b0 T* d 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 \/ y, K- r' ^2 B# g& O 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 i. y& z1 n; ^ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
, n2 { o, o) i, @% ?* y" U/ Z, d 方式二:7 b/ ?0 P9 ^/ v3 |$ U( L
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 h1 A q3 q4 n# _5 k! B5 t SetTitleMatchMode RegEx
% x$ q* k# q7 @9 Z( P return
1 r! Q' i) Q) m5 J2 O& o' y; B ; Stuff to do when Windows Explorer is open2 l6 N. ~ c1 v/ q7 B3 q
;
v# X$ T0 s, s& P #IfWinActive ahk_class ExploreWClass|CabinetWClass
& Y# U: o" q8 ~, F/ [ ; open ‘cmd’ in the current directory
" h& K% w1 A6 I. ]8 a. T! I ;, c' _; A7 E S
#c::
% ]; [+ \9 h6 c6 U* I' }! { OpenCmdInCurrent()# d3 u" z- b" c0 o. |/ z
return6 E. O* ?( T+ Z: |2 t, S+ \1 n
#IfWinActive
/ f( h) H% z5 C4 Y" p; w' y: ` ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
8 v: }* K+ F# S' f- `4 L ; Note: expecting to be run when the active window is Explorer.9 F- a9 Q1 r' f/ v- S0 _+ j( q
;8 O, W1 `5 V6 `- F5 U$ Q( g7 b3 ^
OpenCmdInCurrent()
$ t# |5 H( O7 K9 m4 F' h& }5 k6 }1 a {
+ W/ s. }/ G- O ; This is required to get the full path of the file from the address bar1 j9 q/ Z. c/ H& ]9 a' l9 w1 ^3 n
WinGetText, full_path, A
2 o( j5 }" X+ O- ~ ; Split on newline (`n)
) X. o9 \ J# w( U6 | StringSplit, word_array, full_path, `n$ l- E- i" Q7 \& G, w
; Take the first element from the array0 w9 [ ]% H) Z& \9 @' F& q
full_path = %word_array1%+ r* C+ q" v2 F/ P: c! y
; strip to bare address& F. d; Z. N' Y, j( T" c
full_path := RegExReplace(full_path, “地址: “, “”)* ~) M' G/ [! e; V/ v6 u& z1 V
; Just in case – remove all carriage returns (`r): i. N3 m4 ?! a# m
StringReplace, full_path, full_path, `r, , all" D- P2 _9 j, i- X& o; y
IfInString full_path, \
: Y( G A- N: _( s% x t: [ {
$ U f* l8 z7 A/ G$ j v4 j Run, cmd /K cd /D “%full_path%”
* v1 l3 s6 r8 V q6 m9 ^# b }* b: b4 G! _, T$ y
else% U' [, v: s% N8 N8 j+ v6 O
{
- a- H6 L1 R% j# \4 P h3 G0 \" B- e Run, cmd /K cd /D “C:\ ”3 e( q$ G6 p b' k% d1 ]* x1 K' }$ X' n! E
}
! }0 e3 z- G2 P9 K# i% _1 V+ w }5 e3 @6 K8 _6 [+ z
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ h' h6 o! D4 n* Y
这段小代码肯能有两个你需要修改的地方
) E2 z2 J! r3 q8 c/ v" ~& s 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, p/ {" K x/ d+ ?3 w 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* k* b6 w! S" j* \% @9 i |