此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 Q) |9 ^, u: M; u; y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。' s6 o$ p+ W5 I' }5 j0 B% F
方式一:/ k- Z$ b7 D" c3 ^
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,) P' |9 K6 E: u! T4 |
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 {" J. a5 o# s5 |8 M) @8 G HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 K9 b0 \4 f$ w
方式二:
$ Z, I M/ {) h5 h% B$ U& V3 K 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. l- G) _# s# H' q. L$ p: @
SetTitleMatchMode RegEx! J G: Y9 X9 }, N: O8 o
return8 m) S; y8 {2 n
; Stuff to do when Windows Explorer is open
# u U; I8 s: D1 \) C ;7 |! b5 S; x" l8 [
#IfWinActive ahk_class ExploreWClass|CabinetWClass: k' r; M* P# e9 c2 G' z, e. P
; open ‘cmd’ in the current directory/ P" n8 ^4 @% F1 x. F) ?
;2 Z0 n: l( j' R* y6 K! u' {
#c::
6 C7 T6 |& {; P+ a: J- j) D/ `" ?8 x- K OpenCmdInCurrent()
& T: b4 b4 r) Q5 i H return. G4 W# m" ]# o9 ]5 o: X
#IfWinActive
5 A4 @& A/ @5 [ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ q3 i( r5 ?/ Z/ A/ c ; Note: expecting to be run when the active window is Explorer.
; P" q! H% s, Y! M9 a8 Y. `: [: s ;8 Y$ [$ r; X8 }( n
OpenCmdInCurrent()1 B- |, I+ P& j# w
{
0 b$ v7 Z) v, B6 B2 w/ y4 b P9 B ; This is required to get the full path of the file from the address bar+ k- l! F' p6 S4 O! C
WinGetText, full_path, A
1 g% I' U3 @" _ H ; Split on newline (`n): b+ s7 \. J7 |8 O& {7 v3 }9 q) U* \
StringSplit, word_array, full_path, `n, `4 u, z4 E: e/ o# Y
; Take the first element from the array+ E% S+ p- e/ f% L6 _6 M L! c, W
full_path = %word_array1%
. I" K; {5 t0 V( Q# m0 Y% ~ ; strip to bare address
7 W2 e4 J6 h7 T" U8 m/ z full_path := RegExReplace(full_path, “地址: “, “”): U) z& l0 B* e% F/ Z( o6 F" f. d
; Just in case – remove all carriage returns (`r)
! c- G/ \" o, |7 s StringReplace, full_path, full_path, `r, , all2 O* t7 a& N T' s- ]8 V
IfInString full_path, \& k! C3 O6 r$ N3 i3 k; K
{
3 n0 ^& }/ h! T# C, {, Q Run, cmd /K cd /D “%full_path%”8 x: D4 \, j. `# N
}% P9 u: a C+ f8 z; F
else
" C8 C0 d/ {' q3 Y1 P! t* o) X6 ?1 ^; G {' b4 W) B8 a. A; A0 w4 s* F
Run, cmd /K cd /D “C:\ ”" \- c# i! o$ ^8 [! a0 U/ b
}/ h" t' Y9 N1 a9 A2 h8 ^
}0 d/ P6 X+ Y- {( s2 A+ w- ]# v
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 }2 v7 c4 Q5 j# l* I: O. n
这段小代码肯能有两个你需要修改的地方
$ z0 B# Q u& R5 ^ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
: p9 K, s% Y$ ~& \. p 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 W0 Y1 U6 p, I: ? |