此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) E8 C2 h* k; o
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
; D8 o4 F( D9 C# g( ?4 E7 D 方式一:
. W7 H8 G/ d1 b# N7 i+ L! g/ h 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ t' S6 i F* S9 w- [
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和( K2 X+ V( y! k2 V3 P
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 |. _1 Y+ ]' F( g$ U$ r
方式二:
3 b) h, |7 V, H$ ]" e; x 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- k, T8 F& a% S( Z, L/ C$ k SetTitleMatchMode RegEx# k0 p+ C' p9 e
return7 `) ~/ Y- g2 Z# n
; Stuff to do when Windows Explorer is open( q0 v3 p2 F$ b8 R( S4 j2 a0 O
;* U# T+ b0 ^5 A$ _) a
#IfWinActive ahk_class ExploreWClass|CabinetWClass ^$ I' E+ J* d
; open ‘cmd’ in the current directory
. k( }* M+ k4 x7 }( Q" j" q ;
* f( Q. T5 @) n, A #c::. u) j- E% ^3 L2 ?+ L. \
OpenCmdInCurrent()
) K h7 V: N9 ]0 G# r# g return6 _8 P5 c0 |5 Q" {4 c
#IfWinActive7 J- Y' N" q4 t
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.+ Z; O+ D ~9 j0 L4 W: C6 o# L
; Note: expecting to be run when the active window is Explorer.
9 Q$ j$ B# I9 ? ;
0 l! w0 M' Z4 [% Z7 T* R OpenCmdInCurrent()/ q8 Q$ f8 [. i7 d" L7 Y2 L
{
% A4 [0 E0 ~2 G$ V; n ; This is required to get the full path of the file from the address bar6 J: \: X% G* M& S5 e1 m, N
WinGetText, full_path, A* d* v0 w6 f: T3 `2 ~8 g' D
; Split on newline (`n)
3 g+ Y$ M' O! d5 h6 i StringSplit, word_array, full_path, `n
% B* J5 s4 m/ B9 u5 @ _ ; Take the first element from the array
' g1 m) H9 H/ e5 b; y: b8 B5 x full_path = %word_array1%! y$ l. ^8 M9 a4 u$ c% s! d4 n, b6 |) n
; strip to bare address% X5 I9 u& [. D5 \/ Z
full_path := RegExReplace(full_path, “地址: “, “”)
4 V, Y3 q- [, o$ F ; Just in case – remove all carriage returns (`r)
4 e, h j1 s7 ^$ A- m9 f StringReplace, full_path, full_path, `r, , all, B, c h$ k/ |1 v
IfInString full_path, \$ E$ A0 h1 S, N9 d+ s# n! s
{
/ R; v* R7 F5 ]. z* Y Run, cmd /K cd /D “%full_path%”5 D3 A! G! F6 {" u" n9 N
}
3 s5 [, X6 z( f2 {' F9 f else
/ I- `' G, t, {! C- w h1 G {
' m c6 z, D" J# L/ a$ M Run, cmd /K cd /D “C:\ ”) H$ u5 K. m1 G+ E+ @" n
}
: _# U9 C6 @" \$ y$ i }
7 N! B p6 Y$ \ B9 |# ` 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
, r. y( L# U2 e4 u4 B% m 这段小代码肯能有两个你需要修改的地方9 w( B& Q- B; c- L8 ]
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键 \, x* ?3 b8 p9 [) u
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
O% x- A. `" w% ? |