此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 N' C. N3 ~- a4 a& Z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- {; N2 c- z( z( J) H( D& N2 j 方式一:
/ W& d( N0 c4 \ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 \/ r: f2 A. B/ |
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 v% Q4 a3 W5 P+ b" S$ D. G7 o
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
$ m5 j* z2 D7 N% T 方式二:
5 @5 l+ j" h4 ?3 F 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 D4 |' u2 N6 @! x2 `5 K) [
SetTitleMatchMode RegEx; S1 F, Y6 k2 Q8 W9 Q( h
return
" o* t: U& q& l6 B3 {7 {( [ ; Stuff to do when Windows Explorer is open6 Q0 c$ W6 I8 ]" g, U( U" u" C
;
+ q; A) D; ^5 G$ m6 t* A #IfWinActive ahk_class ExploreWClass|CabinetWClass. k0 v! t! _8 ], k
; open ‘cmd’ in the current directory8 t- P' J. }# V- l1 \8 x
;
" Q, [6 r5 I8 w* ?7 X0 N* d( S #c::9 M: ? M1 r, l) [. h5 c% b
OpenCmdInCurrent()
2 |. _. ^+ T( p% p5 H/ d2 q, g return
# z7 G( L: X' v% C( C! g #IfWinActive
. ~5 m/ w0 S% X, l# c) e4 _8 t ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 i/ W& L5 e- e; z j ; Note: expecting to be run when the active window is Explorer.2 Z7 M7 Y8 |- }' _: }
;
$ J+ L) J! l' c# B5 @ OpenCmdInCurrent()
! y. x: J4 N3 T' H% ]5 A* P {
: h6 x7 N# O' Q& B ; This is required to get the full path of the file from the address bar
# p. t, \8 k% g. ] R4 \ WinGetText, full_path, A: C; N: w7 g6 C( J& I" b# u
; Split on newline (`n)
. _- e! n5 K- y& J$ m StringSplit, word_array, full_path, `n8 d- i: p6 W. }& P8 }7 i
; Take the first element from the array6 H9 U* v3 }* \& a: J, ]
full_path = %word_array1%1 l* }9 \, O9 U/ k, n/ {& u2 M, Q
; strip to bare address
1 G4 E2 [5 F; D& n full_path := RegExReplace(full_path, “地址: “, “”)
; p: Y. p" L5 H- W ; Just in case – remove all carriage returns (`r)
9 ^( q* ~/ @( C; o; |- G StringReplace, full_path, full_path, `r, , all
* [+ T8 b/ t+ U# s IfInString full_path, \: ]% ?2 I! y- @# U) |
{
% S) y8 }$ x* A9 {7 r8 V Run, cmd /K cd /D “%full_path%”& a9 M+ O, N% r# E! x
}
3 s: {! |% t+ ~1 J. H else
& W9 u1 P1 l0 J( W& N! g {$ F, l$ J1 i/ I! I# T7 t
Run, cmd /K cd /D “C:\ ”
' S$ n( B. X5 e; X* H# I" [$ k }9 _8 T5 J) m% W; |$ ?* F
}" c& T* N( ~3 l2 @! m
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
+ |) a) ]: V5 ?6 Z+ x 这段小代码肯能有两个你需要修改的地方8 N- N, G- Z: Z1 G7 f4 C& q7 s4 d
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- `; E* N, O: m* B
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 ?, v! N+ _, ]5 X5 S; U |