此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 P, |+ k; L: o; d# ]$ j
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。; J; x1 d/ q5 m4 U
方式一:
; P5 }! u6 ^- ?) _1 r8 X$ r 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 W; S. ~7 ?5 |& f. V7 p) v
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和2 P5 H1 y9 @& d. _" Y# |
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 i7 N9 @3 {# Y9 q: E 方式二:
U2 F1 g" A8 q7 o; b7 o6 n, N 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; B4 J; V- O X0 g: u& n( b6 a SetTitleMatchMode RegEx7 n1 W# X7 f9 U5 b
return2 Y7 r; V* S+ d1 A
; Stuff to do when Windows Explorer is open
( W. v: G9 Y1 T* ` ;
' J9 N3 B5 f! e #IfWinActive ahk_class ExploreWClass|CabinetWClass
# B+ i0 Z0 q1 y6 ? ; open ‘cmd’ in the current directory
2 E% X8 ^2 j* C' Y ;7 O7 s9 ]+ L: M# A. F
#c::
) ~0 m6 H( O; @: m6 Z7 \7 n& j$ C! O OpenCmdInCurrent()' H* R! [& V" \3 c$ o
return
2 ~4 g m; ^# |5 `. X #IfWinActive* }6 [( S2 H: j( ]
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.3 U* i0 ^* w2 Z! l
; Note: expecting to be run when the active window is Explorer.
6 r. M( c" M' {$ m Z! y ;
$ B+ e3 s( ]) x* n$ X# } OpenCmdInCurrent()
. T+ j- w* e2 Z. r3 l {4 S( P7 Z# W7 M$ i& l
; This is required to get the full path of the file from the address bar
3 E! I, v5 \$ [" g WinGetText, full_path, A7 S! o$ C6 ~' D! [
; Split on newline (`n)
! p* P8 b+ L& z5 p StringSplit, word_array, full_path, `n% ]( G" D2 W( X+ ^5 R H7 }7 ~* y
; Take the first element from the array
$ q9 Q- {! n" e9 X2 p# m9 u& y( u full_path = %word_array1%
& ~" h2 O% n) p! w/ z ; strip to bare address
$ ]3 a K5 V# f3 r; Y/ Q full_path := RegExReplace(full_path, “地址: “, “”)
' f+ D* V& U7 E$ F- X7 p) k5 G ; Just in case – remove all carriage returns (`r)8 B( }' @' J5 ^6 T3 w6 k0 o( X
StringReplace, full_path, full_path, `r, , all" b# y: G- ^9 ]% m% I3 l2 C
IfInString full_path, \& K) i* V# @8 X6 ^* s3 C1 h
{# f: a8 O2 [( Z9 |) n* r
Run, cmd /K cd /D “%full_path%”
v& T* ] T6 S1 { }
7 j. x _, T" `. | else7 M y: F0 t1 r6 \- X( W1 ^
{
, d3 h, }% {# r) j7 A Run, cmd /K cd /D “C:\ ”" I4 e6 V$ U( |) ~
}
/ S M- C" J+ f$ C( x$ G& x2 ^ }
2 D1 O o6 W3 c# H* X& V 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: `+ {$ ?/ ?8 Q5 Q
这段小代码肯能有两个你需要修改的地方
" R) j% o/ m2 n; ]7 W7 D: @ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% S) t; _, a' s$ n- C- i C: \" ] h
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
' {! S, w# C9 k# R |