此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。5 u8 Q+ w" H l
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
6 R. j2 {/ l' k/ a7 b 方式一:4 N' O) K8 d- _/ }# B
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 u7 q3 B+ j7 z/ t$ Z0 P7 }
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- s! X8 U) e! D4 }' Q HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。& ?1 F" f# s9 K8 Z+ ^) z# p) s/ N
方式二:
1 ?5 o r4 G, [ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:* O( l1 q+ h! g9 p* r
SetTitleMatchMode RegEx6 o# t% J. V5 I; h& t
return
/ [" I5 L: w/ u+ o6 [* h) H6 l8 p& @ ; Stuff to do when Windows Explorer is open
% L; K R5 ~& P- E+ m) x; V ;
% J! a8 F% D" H7 |* d. U #IfWinActive ahk_class ExploreWClass|CabinetWClass' V( B% s& t0 w
; open ‘cmd’ in the current directory
0 y5 ~5 r; q4 Z( r+ j ;
) L% I( @4 L, G7 x$ ~: T #c::7 V; |( K" t& }' E
OpenCmdInCurrent()7 b" H& k+ {# H; p; {0 |0 @
return
: }8 V8 X' |/ c9 D' h1 G/ `! p #IfWinActive3 o% A0 q7 y' S& p% S
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 j3 i( L+ R- H9 E& q( r, x
; Note: expecting to be run when the active window is Explorer.- }6 J. u9 X% ^/ z9 I7 s+ w
;
( d* V- Z! B: s1 ] OpenCmdInCurrent()% [% K* I$ g8 F( B- F/ z- u
{! \' v; g u/ R5 ]8 k
; This is required to get the full path of the file from the address bar
. P0 m( s8 h- r2 C! H* A WinGetText, full_path, A: i9 P9 W& j2 m. j/ o4 M p8 Y
; Split on newline (`n)' a: a3 G: F% s {+ G1 Y
StringSplit, word_array, full_path, `n" v8 g5 U) M9 Y* L0 U# U
; Take the first element from the array( h$ l5 f% `0 a: a. q
full_path = %word_array1%
; E1 @3 Y' L0 F7 X ; strip to bare address& W" F+ r: A: u' D8 c
full_path := RegExReplace(full_path, “地址: “, “”)2 o5 A4 W! o- I& r+ e, u9 t
; Just in case – remove all carriage returns (`r)
5 a/ { s! @( t' s4 j. W9 h/ w StringReplace, full_path, full_path, `r, , all8 [3 F- r; I( S; Q+ f! N
IfInString full_path, \6 _" H) \5 u- e
{
" t. K8 v6 R5 A+ N" L Run, cmd /K cd /D “%full_path%”8 ?& l5 d1 ]% r" M" G, M& N7 r
}
i& g5 [9 r$ M8 g' T& U else
`8 x" _; ~6 _; k; C {
* L2 j0 }6 n% f$ j& B) v Run, cmd /K cd /D “C:\ ”$ E9 n: |3 ~$ W5 j- o
}! o5 Q' }7 ?" ]: ]4 _. z5 f
}3 I" V: I* i' V/ L) E9 W8 W, [
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" s0 d# z3 c2 E7 a% p* W' X
这段小代码肯能有两个你需要修改的地方+ U2 D) Q7 O' V9 D: f
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
: _* A* ~, x: s6 u 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “* \5 }5 A8 d' u6 \5 S1 j
|