此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 P) a* I' ?: f6 Z& C
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, N2 ~2 P+ e" d5 y
方式一:4 u9 [) q0 n y4 I; b; P- K
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
! \) e. T9 u5 V% S' Q 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) O; f. U9 i/ k$ P
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。. J; H! j9 w; Q
方式二:
. s8 T3 C! x6 y' v 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 a: ]) x" C) u6 W' M' X; p SetTitleMatchMode RegEx
; M; P4 L3 d5 u: _# X: G return1 n$ {# D$ Z' v- \/ Y& M$ F& u6 R
; Stuff to do when Windows Explorer is open* Y4 a" E+ F0 }3 A* c+ f/ ?& f$ A
;
8 J7 }8 | r. ^: N% t* Q #IfWinActive ahk_class ExploreWClass|CabinetWClass! V) ?2 l( L7 R# A, T" S: O
; open ‘cmd’ in the current directory
% h4 J' f. e2 v, `2 N+ R% | ;
5 a0 g2 e5 H+ z6 i) g #c::
- I8 i# ?& g/ t& T OpenCmdInCurrent()4 t- l, z* J$ E' A* A* A
return: W6 B, R4 z, x1 s5 X' u& ?$ U( N/ g
#IfWinActive# }7 y- J0 Y) i7 R, k& p0 P
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 e; ^4 S( g+ @3 k ; Note: expecting to be run when the active window is Explorer.$ m! `' n: c+ ~0 \1 P# L
;( L+ ~) c/ t8 y5 M% R, j
OpenCmdInCurrent()
- s. l* v0 S6 v( ?, L# v {& P. h/ _' ?. V* q
; This is required to get the full path of the file from the address bar/ b0 G+ N) Q% S5 ]) U U1 I% m
WinGetText, full_path, A2 Z: h @5 L Q' B4 N- x
; Split on newline (`n)2 e) Q' g2 J0 {: K! F: [
StringSplit, word_array, full_path, `n
R( N# r; n; Q5 ?4 D) m6 q/ u ; Take the first element from the array
6 e. a3 S! _- ^- | full_path = %word_array1%& {; x! k5 V* T, e s
; strip to bare address- h& m. S8 x; c/ m
full_path := RegExReplace(full_path, “地址: “, “”)
0 K: T# l5 ]# ], O& \ ; Just in case – remove all carriage returns (`r)* Y( }% D; _) `) x* N0 C
StringReplace, full_path, full_path, `r, , all
8 a& m! M9 R+ K" ^- k3 }* g IfInString full_path, \
4 S* F& J3 k$ G {
1 d3 q! i2 a/ ?; [5 V! r+ G Run, cmd /K cd /D “%full_path%”
8 F* q/ K& k+ ? }
4 h) N7 ?1 @9 [2 {% M% A# M else& ?- T$ f1 c; ^8 z0 R: H
{2 K: K7 B; ~3 K: P0 h( S7 l
Run, cmd /K cd /D “C:\ ”2 @% D7 i) F( j" s, o' x1 y
}
: y5 z: \" s+ n! f; T: r9 \+ f }
: Y! a/ f/ t9 A' E 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 k- h" Y3 Q2 x& P9 S 这段小代码肯能有两个你需要修改的地方
: H" g8 m9 i3 V5 i1 Y* B 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键! J. n. U0 A' e/ ~ D4 `
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “/ C& C) Z; j) `
|