此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) ^# e- C( S, H
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
5 t+ I5 a; \6 o, l$ n9 @ 方式一:. V0 _; o8 ]# E5 }; _
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- z Q5 U8 a8 @# {8 a
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和$ f! T3 d0 q8 U) m4 ^, }
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 V( N6 c. n0 q9 U
方式二:
5 b) o, i1 N+ } E 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* H ]. `/ @1 ^0 K/ h SetTitleMatchMode RegEx& \" \+ L" A) h) w( S; Z
return
p1 _. i! j2 m ; Stuff to do when Windows Explorer is open
/ `2 \1 Y% F: Y2 d# @: I ;
( O( x% Y7 ?; e- ~( d% c #IfWinActive ahk_class ExploreWClass|CabinetWClass+ x Z; p' i: J0 I; y2 a
; open ‘cmd’ in the current directory* j# `, k, B' `
;: `& N, J0 Q/ ?1 W: J& S% \% c& c. _
#c::( b9 z; H9 q4 e) W: I2 H
OpenCmdInCurrent()+ P. z+ W7 j* L# f" R
return
# G5 C1 B4 [! H }( _ #IfWinActive
/ W9 j+ \, {) ~6 K6 C# J1 | ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.- I' r* y! A# q% y3 u" u
; Note: expecting to be run when the active window is Explorer.. Y! n9 h4 h$ k8 H& T& W
;! F: |& d1 N# t7 k$ _5 j- q7 T4 g
OpenCmdInCurrent()
7 c. ]. ~, _( t7 q: }2 @* Q {& ?# }& h: @( w7 f
; This is required to get the full path of the file from the address bar
6 K8 M/ N6 L) L H: t WinGetText, full_path, A# H7 J- t+ D' y) j3 V0 q
; Split on newline (`n)5 m, ~% y! {) w' p4 Y
StringSplit, word_array, full_path, `n
. c' m z' G3 M$ |8 g3 V; A | ; Take the first element from the array
% I# W" D3 J8 O- E5 |8 V, y! r3 h% Q full_path = %word_array1%
% V+ [4 [0 t' [* l$ | ; strip to bare address
: W+ d! i }" N, y# Y. F9 | full_path := RegExReplace(full_path, “地址: “, “”)0 J( k, C2 \: s" C1 G
; Just in case – remove all carriage returns (`r): S/ Q* D' ?( L6 \+ _2 O
StringReplace, full_path, full_path, `r, , all
r2 C, N) r2 z! ]8 `. L4 X' E% Q9 x( u IfInString full_path, \* I. |: Y/ Z3 b ]* L
{) y* X% C# U' c X# b8 U% [3 l
Run, cmd /K cd /D “%full_path%”' E& }$ d- m4 s t6 k1 Y
}
' J3 D( @+ A x$ Q* J5 l else
( x' F+ ?0 m6 x h, ~ {
# H- g, k' Z! n- k) c' G& U Run, cmd /K cd /D “C:\ ”9 {4 t! l6 K* T8 a G* u; A! N7 B
}
5 i* `$ e8 ~7 u* W! T2 Q2 t# V* w }
$ \% t! [9 `6 H% S, [* p 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: c S8 i- K% A b' L, T3 J# F
这段小代码肯能有两个你需要修改的地方
9 a# P6 }% s. d& m0 C- Q! @+ [ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 S$ l) z" B; k
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 w8 X1 K: Q4 z# o
|