此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
" t/ q* `4 ~/ b% c _ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 ~, n- L* C" d2 o% x
方式一:' F' e' Z/ R2 s3 O: j) U
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
z2 |) q; @* Z+ D( X 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 \! R& O' [1 G: C# L/ M HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。% c4 j( f# f5 S7 i4 G: b6 O
方式二:4 d. o6 @4 v7 C& N* j9 D' W& M4 Z {( D
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" [3 s( k; S" G" P. ~6 W SetTitleMatchMode RegEx
s. ?2 H) O1 }$ y- b* @' X return
; v( Z; r) I' z' X+ ]. {( X ; Stuff to do when Windows Explorer is open
' Q+ D3 g0 X, s7 n0 W ;1 S6 s) s( l; T( _2 z& c9 c8 y
#IfWinActive ahk_class ExploreWClass|CabinetWClass& y, n: }7 R8 Z P3 z B& \( `
; open ‘cmd’ in the current directory
7 ^# G' k& b4 E( {5 T' f T' A, @ ;7 j% H6 k' D" r4 A; N }6 Y
#c::$ W2 [7 E# q! |% I) Y( ^
OpenCmdInCurrent()
4 m" p8 Z) e2 o( ~" m return# k; D& F6 C' j) w+ W, `( w+ V F
#IfWinActive# F4 t; Z x$ l
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 `( M8 s# O5 c
; Note: expecting to be run when the active window is Explorer. N+ E. _/ }( T
;
! a% j$ X! P5 n8 E1 A b0 x OpenCmdInCurrent()2 @5 C3 G# J# a) G
{
5 }9 _" B- ~& L. G3 C$ k6 }0 S; M ; This is required to get the full path of the file from the address bar
1 I6 }, C4 U+ O! u% z# ~ WinGetText, full_path, A
$ i& p8 k3 K- ] ; Split on newline (`n)
# ^& u9 Z" \; f, a; X0 ]3 v StringSplit, word_array, full_path, `n6 G( S4 K: ]; n+ i+ P4 ^) z
; Take the first element from the array
3 a# P8 A+ e0 b6 F, i full_path = %word_array1%! L1 b2 C( H0 M( j4 n# ]& t7 o
; strip to bare address
3 N# L7 S. W+ H0 P$ o full_path := RegExReplace(full_path, “地址: “, “”): U8 T* [* @' e& D2 `* F; P8 O
; Just in case – remove all carriage returns (`r)
) V4 N6 x6 A; _: u StringReplace, full_path, full_path, `r, , all
# f) _/ ?! o- t IfInString full_path, \$ ]5 S4 N& Z( L+ ^+ [: O" }. f
{
* T3 O* h- y, U5 G2 G' q Run, cmd /K cd /D “%full_path%”
. e% L! R0 `6 U7 Q) \9 s+ ^ }
+ j% E4 f( O4 ]- U: q( Q( O) d else7 [, X: z) ^ X, ?, u C
{
4 k3 [* U, k1 N! T0 u/ K Run, cmd /K cd /D “C:\ ”
' X3 ]5 d# ?' G" ^- c }( b2 d7 _8 e" w5 G/ M" y' L
}+ Q0 [* U5 \: D$ t
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ M5 X5 u1 B/ m$ r
这段小代码肯能有两个你需要修改的地方8 |* y3 y, _- t6 s0 {$ _
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键 D3 F, I- o" }1 t- d
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 ?: n8 b5 B/ v6 N3 U. v) W0 W1 J |