此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 w- q! a0 x0 ]- V4 @$ l0 g0 O7 S
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 i* D5 \) N9 ?6 a' x \
方式一:
: p0 N5 y* p, z% h 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 {" [: k: y- Q9 ~: e" B6 o 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 h* O, I4 ~5 C$ F HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! e% F( K6 i+ Z. J m 方式二:
2 i2 i' ` A1 b! t' m8 ~' X, X 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 |/ W* }8 E- g j1 t" c: D- X
SetTitleMatchMode RegEx
) ~) R2 L5 l" d! Y2 J return3 G. o5 o/ u M/ e# X: j
; Stuff to do when Windows Explorer is open
0 F% y3 F( J0 l' P2 l' } ;& m) O+ |" n, I2 G" {/ m
#IfWinActive ahk_class ExploreWClass|CabinetWClass F0 O. B9 S! z. f% a
; open ‘cmd’ in the current directory( X I. C1 z5 H" \3 h! ?9 I7 }1 M
;
8 e) x- Q/ o5 M- V# @7 _ #c::
! _1 u* W! d2 ] OpenCmdInCurrent()
/ `/ H& C4 _6 ]* D1 E return
) F" K! Q% |& G" e" e4 a! j. z* R( B #IfWinActive6 Y9 x" c& O5 T, c
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( I, C% F$ H/ V/ \1 ~
; Note: expecting to be run when the active window is Explorer.
2 {" I7 M$ `* s" q% m$ f6 P ;
- E4 S1 G2 t2 w' \ OpenCmdInCurrent()0 i. `+ v1 t C- L8 B) ~/ [
{4 I$ l9 ~. u' K3 f7 Q1 R
; This is required to get the full path of the file from the address bar: s$ i7 f6 L) S6 v7 n9 ~% I( D) p
WinGetText, full_path, A6 `+ S5 A! b$ j- P& N9 Z9 J) c
; Split on newline (`n)
' Y- m' G. ~8 O& v9 V StringSplit, word_array, full_path, `n
( k( x4 e X$ w5 m: H$ F ; Take the first element from the array
% O) u7 D+ I: Y6 m9 l6 E* w full_path = %word_array1%
9 |) X3 ]/ S" r- `) |# @0 ? ; strip to bare address
) h! O$ D+ N& x2 h+ I full_path := RegExReplace(full_path, “地址: “, “”)2 B9 e2 D5 ? J
; Just in case – remove all carriage returns (`r)1 s. r$ \4 N1 | J) x* U7 b' u1 Y
StringReplace, full_path, full_path, `r, , all/ E' t8 @- F9 T3 j0 y! ]* f
IfInString full_path, \
5 k- n* o2 F. p' D ~, v {1 ~1 E! Q: R* J$ N, \5 ?+ f
Run, cmd /K cd /D “%full_path%”
7 s$ O* y; j% I8 Z }: ^& W0 u0 F! n6 G5 g) J
else) o; E" O" S1 p {# z- P
{
) M2 R/ x: [) [4 ~+ d, S Run, cmd /K cd /D “C:\ ”
\) ~6 _' j1 \8 h }3 j. ]# Z! u5 U ?7 {
}
: |$ _% C _ G; t8 I 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( Y4 _$ B& \" H0 @( K4 E
这段小代码肯能有两个你需要修改的地方
2 O! [! x' Z$ W* W @+ N: H 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键* ]1 d8 @0 @+ M; @
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 C5 ^" P% c' s! Q% ?3 A) a
|