此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
/ H& m" b: i7 }3 i- S6 i/ ` 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
; @/ J) k3 m I. |1 l 方式一:9 ?. U. T) ^4 g6 M \, c4 y, G; S* k
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# X3 P4 _% M! j R3 }5 g
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
* s6 H' ~7 `( h5 j, y- w HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。$ q, t o% X/ w7 U" r
方式二:
/ y5 o( z6 h( v& f& g4 e" u 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, ^/ e+ d8 Z5 L, t1 S# y
SetTitleMatchMode RegEx
6 K" p/ T% L. w& z5 T, e, r8 ] return4 q5 u8 N. k- _: x/ s
; Stuff to do when Windows Explorer is open
7 P9 S# S/ G2 i2 ^6 N/ i$ ^* r! ^ ;" m! h8 {$ J1 u( m J) B
#IfWinActive ahk_class ExploreWClass|CabinetWClass' c- z$ @, c7 L$ Y1 K- e @& i8 ]
; open ‘cmd’ in the current directory' i: M: _3 T- e# D4 n3 S
;
- Z( O& X% U4 _ #c::
, @" U- \5 i8 w& |" y OpenCmdInCurrent()9 P2 x& n' j6 u6 U" D& r
return
6 n1 I8 N7 F0 P+ } #IfWinActive
5 o6 O0 k/ W; e! e2 `6 i ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 y% u- J7 S( ?; }. Z7 N( n" i
; Note: expecting to be run when the active window is Explorer.: }: l4 I, q" x( `6 R( b
;
/ G& G* @5 X( D OpenCmdInCurrent()
. ?6 N( y# \' ~9 X, \ {8 e* k f9 p8 j6 q- ~; T- [
; This is required to get the full path of the file from the address bar
, \' B6 R# i7 Q' b) Q- ^ L+ ] WinGetText, full_path, A
# |9 ~* N+ b7 ~; Q2 N: R( M+ p+ S ; Split on newline (`n)
3 y9 }1 a+ r( p9 O' E1 `- d StringSplit, word_array, full_path, `n
4 B! l; t# K$ |1 p3 y8 L ; Take the first element from the array ~ X" _7 }4 t+ a m k' ]! n
full_path = %word_array1%
% I; K* x; h1 Y ; strip to bare address
/ a* p: w9 k* [4 a( c$ n# n* t full_path := RegExReplace(full_path, “地址: “, “”)
: d. U. E$ s' r4 M, `1 R" A ; Just in case – remove all carriage returns (`r)1 B$ C- z& j# B' D9 t# S
StringReplace, full_path, full_path, `r, , all1 Z2 R/ a6 T, e* y7 ]
IfInString full_path, \
& v" h7 z1 h4 p0 l9 d* q& O {
+ T, E+ U! k; { Run, cmd /K cd /D “%full_path%”( V* J" [ p% S, J% \ y" K! [2 q
}
# Q* R7 z, ~% r3 o else, o) F! e) Y) h
{
* S# [) `, e Z4 F Run, cmd /K cd /D “C:\ ”
: o( S% w. R* j }
; l0 C( ^. r+ P/ R& v }- p8 d d& W9 _, y! f0 ~
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。4 J, K6 z9 \# B; V
这段小代码肯能有两个你需要修改的地方8 O, H, @6 B, W# r. R4 k7 y, T
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; c7 m; m3 J, S: e6 H4 H6 B& o2 k4 A: m
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; [1 t, e; s. F J$ i0 }/ E
|