此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! n! \1 w1 m3 |; X, Q/ X+ s) Z5 |8 H
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
5 r+ Q& O% y x3 e) ?2 N 方式一:
/ A7 p# H5 x' D, t0 T" k 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ t7 Y8 y9 O' [" n 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, v6 t+ r9 }9 p- H3 p
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- W4 k% ^- d3 s6 x& N; j! H/ C
方式二: j$ x7 L, I0 V% w% I! B
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) h9 o: d9 C& E! @8 G4 u* } SetTitleMatchMode RegEx* U/ A2 O9 N3 d2 e
return& O3 P# J7 b# p
; Stuff to do when Windows Explorer is open: y2 ~$ B6 N4 f8 f! T0 v
;9 Y2 b5 n0 N; I: _" A8 h
#IfWinActive ahk_class ExploreWClass|CabinetWClass6 r! F* e$ i" I* u$ q3 k! n3 S
; open ‘cmd’ in the current directory
- |2 j# s! p n' b' k ;% X& _+ E; Q9 o% C _! b, R
#c::
|& c& F: Y1 H3 F OpenCmdInCurrent()' e7 ]! D7 C: j @: {- f
return
3 `( U5 ]* t- C5 m, E #IfWinActive
2 t o: B v' W ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 t0 x2 p, |1 r. p+ A
; Note: expecting to be run when the active window is Explorer.$ e4 e% a- B/ o5 J4 U9 V
;
6 D4 |) v5 G: d& {- `% [ OpenCmdInCurrent()
4 t" n; C) ^8 K. ~$ x {
~; Q: L4 }: N+ `4 L ; This is required to get the full path of the file from the address bar
! x4 w, v5 \# |! Y) O5 H2 S WinGetText, full_path, A
5 \% B8 W. y# z- X: { ; Split on newline (`n)
7 }9 {7 j+ ?2 {( O: }& O0 }- E StringSplit, word_array, full_path, `n
% q! q# L# X% B4 V; Y/ @6 j8 ]( ? ; Take the first element from the array
& J( n9 b9 C' i( r8 k3 P full_path = %word_array1%3 j6 j3 q" v& ~' |& \
; strip to bare address: {9 e3 P( _5 D* Z
full_path := RegExReplace(full_path, “地址: “, “”)) { [; c3 ^% n# Z. Q4 x
; Just in case – remove all carriage returns (`r). \# q% U. C: S9 C. J& W. {
StringReplace, full_path, full_path, `r, , all
3 c/ `( D* c# G7 m4 g IfInString full_path, \
" t: p' B$ d2 J {: p8 {1 Y4 `) s2 U1 v! h$ Y
Run, cmd /K cd /D “%full_path%”" O& `1 ^4 S9 N9 g
}/ S/ [9 {( v& d' ]5 M. b" Y
else. I4 k" e( i2 L+ H
{ @9 d. S& e5 e, y+ e# E# F
Run, cmd /K cd /D “C:\ ”- W5 L/ x) O1 H( e
}
6 @9 d# F6 O. F. A. A }
3 d5 q* T! V! j5 U/ ?7 | 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
% t) \, n. f- F7 W 这段小代码肯能有两个你需要修改的地方& L, C: Y$ w$ i. x
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- r# Y. N; ^( H* T- L8 Y( a, [
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: H# R. A( {3 v4 _. [ |