此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) i3 c" Q8 \1 Z! G1 S& d2 }2 v) r
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* e c: o2 p6 O) `. I
方式一:
: b) |' [) A; f 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* W6 Y1 T3 v( \ T! S9 P2 u4 G
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
$ h$ ?! _# U: n7 z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 l) _6 n1 y+ @% w. q5 i" r2 P
方式二:
U- W# m7 ]7 [$ k( i R/ s) _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; R6 x4 W3 A, `, X SetTitleMatchMode RegEx
' s6 O+ e: G/ W5 K" {0 P- [ return
; }, a; `/ C9 C; o0 q5 V. r0 ~ ; Stuff to do when Windows Explorer is open" [) q5 O3 u F# Q9 b
;
; i- p& d! A& H: ~ Z) A #IfWinActive ahk_class ExploreWClass|CabinetWClass3 ] p/ L, G- z R# [) n
; open ‘cmd’ in the current directory+ [" P$ a! z6 R
;
( U5 O* D4 S H #c::
0 b( S U0 m( V1 L u OpenCmdInCurrent(), ]" s5 ]5 h/ m/ L3 e9 z+ E# G
return
" u+ a1 \/ D3 V5 K: O #IfWinActive, B0 N6 Q9 a& X$ C
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' }" @$ F, b6 ?6 x- V- M& a/ I ; Note: expecting to be run when the active window is Explorer." }. J* S7 p2 ^1 T
;1 W5 p! U# A F& r3 J4 H
OpenCmdInCurrent()
5 x1 t$ ]" s f) g {2 ?9 @; b* x, R
; This is required to get the full path of the file from the address bar
/ z4 W) }5 N% n6 @8 d+ }+ e WinGetText, full_path, A8 L8 T# P, G( A9 S
; Split on newline (`n)
) B; D- l) ]: K% v9 y* N( r StringSplit, word_array, full_path, `n
4 r; x& X; j6 C$ h! I2 x) x ; Take the first element from the array# p* N$ l( ~: J
full_path = %word_array1%6 K; |5 |7 s5 C: Q" D
; strip to bare address
* @6 b: D1 Z2 Y2 R s; e% b( u full_path := RegExReplace(full_path, “地址: “, “”)
% t0 `3 l9 O$ T* h: d3 F- X ; Just in case – remove all carriage returns (`r)
( [8 O& p: o, m S' D2 o StringReplace, full_path, full_path, `r, , all
, t2 ?% _% c7 ~1 t/ O IfInString full_path, \$ W( U; f9 y8 I& r g1 M( V
{
8 p5 {, k x' s# [' Y- C; W Run, cmd /K cd /D “%full_path%”" u5 I# v+ v3 e- ?' u5 L
}) B( x/ D Z& X
else/ P- k, | D7 k8 z8 P+ J
{5 ]: G0 T5 R" @' K3 w
Run, cmd /K cd /D “C:\ ”
! D1 o9 J: Z4 G0 [2 l9 y }
9 k% R0 K% S& T5 W, O9 ?& q }
& Z$ B0 V0 }2 O' H9 C8 ^' @( m 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。. E" d: i. I! c. I/ X
这段小代码肯能有两个你需要修改的地方
% x; ~. {1 p+ d! Z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- y5 f P6 X4 M3 l( ]0 J 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 u! ^2 G9 ?0 o( M/ X- r
|