此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 n8 \3 N( g% {% I$ M6 e 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& Y5 G, ?6 |* I {4 q' ^' e' N 方式一:
1 @8 m5 k: v v$ @7 B- V 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
{0 \( V$ e9 b2 | 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. d( Y' s5 d6 D- F HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! U" S0 B: g- K7 T- y, E P
方式二:
" V8 g3 S( h0 q1 N1 P 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
: }% h( {/ e8 Z% k8 r, a- i7 [/ h SetTitleMatchMode RegEx
- }( f4 W' r0 j( `) [; ~, {7 R return0 O! C. S2 L. C) [, u
; Stuff to do when Windows Explorer is open5 w {( _7 p, R! @) g
;2 F, W! h5 h. r+ j& o: g1 b* `
#IfWinActive ahk_class ExploreWClass|CabinetWClass
/ q- _: I$ N% B9 O9 I ; open ‘cmd’ in the current directory
4 ?0 w/ q; W n+ q4 [ ;
1 n) ^" K4 b) [* e. h) h4 O #c::4 a( p+ @ ]# x6 Z4 h6 k! X+ w2 P
OpenCmdInCurrent()/ b. V: A [0 G: u/ ]
return
3 O& ?9 ~1 t# P, e #IfWinActive
9 w3 ~ q# ]. \! C1 j1 R- H5 s" f% m ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- i! Q! X: }" U ; Note: expecting to be run when the active window is Explorer.
! {' j- x6 P; n$ ]: k ;
. l3 i% f$ y8 N: n OpenCmdInCurrent()0 u, M, P. K( q! H N& k6 A
{, z* F g/ H) }& o2 Y# C& y5 |
; This is required to get the full path of the file from the address bar. w0 [- a+ _' E7 N; d3 x
WinGetText, full_path, A
% A! H# {9 |' R1 E& e$ j6 N$ G$ ?& | ; Split on newline (`n)
9 r& \+ P1 `' a( \2 m* c StringSplit, word_array, full_path, `n1 R8 D* D5 h: p6 W6 d
; Take the first element from the array
+ [) a+ G2 l$ E1 V' C2 f- s0 U7 Y full_path = %word_array1%* p5 \% D" W2 N! I) m) K. g
; strip to bare address
' j, C4 k# ]: {& E1 |% \6 F full_path := RegExReplace(full_path, “地址: “, “”)6 H1 o' ?: D( }0 [) K7 A- k
; Just in case – remove all carriage returns (`r)+ D! x0 U) k8 {+ v, g" G
StringReplace, full_path, full_path, `r, , all
2 u1 l j0 ~7 ] IfInString full_path, \! @) T; X; P' z+ \. {
{3 g: z) W. J6 A8 h$ Z
Run, cmd /K cd /D “%full_path%”! J3 W! }# v9 z! h- e9 D+ O' S s
}* |, K: M5 D) k' [9 m& Y' c- [
else
* q" i6 } _5 P! y {/ F2 @! T$ }1 F6 b/ R4 n+ Q
Run, cmd /K cd /D “C:\ ”( i& T$ ^0 g# i: o* R
}
( J( p0 n( p* w8 Z5 V3 q- d7 @6 T }
6 q9 m8 I0 p" D1 D, \/ Y 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: e% W* D# w! U 这段小代码肯能有两个你需要修改的地方; j3 j( M9 S2 K' I1 {2 ]) M( s/ n: h
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键* y6 |" n+ T% F# |
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ J9 F* D* a+ k1 j1 s3 @: J5 Z |