此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 u6 q. H- [5 R" v. A1 d 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 J1 h7 U) z0 u# Z5 r
方式一:
0 |1 M5 p" J k _ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: A! t! b; t2 f0 a! L0 s0 ?, V 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
3 E1 H) H' ]0 x: X- ~3 N HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
% v/ z1 v/ A0 x) Q. U 方式二:
) L2 e% X g1 E 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) r2 x* w' M) J' X1 h8 Q# n: g SetTitleMatchMode RegEx; }% d4 d" {! _# \
return
# T& i# o; O% F* ]/ s6 `3 f ; Stuff to do when Windows Explorer is open
) z4 |. Z7 `1 h2 E3 y' E ;
- A6 ?4 a+ H" ^ Q2 w #IfWinActive ahk_class ExploreWClass|CabinetWClass
0 K0 |6 g6 f. s8 p1 V# s ; open ‘cmd’ in the current directory- E, [. c1 X% ?
;( o- e$ N' T- m0 S
#c::4 p' k) V+ m r
OpenCmdInCurrent()7 H( o9 I2 h: D# U7 Y, k
return+ i+ G9 U# m/ l0 n
#IfWinActive* S* B2 Z% o8 S! M. H: E! z( L6 g
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* r9 ^, i& k( J ; Note: expecting to be run when the active window is Explorer.
7 f. m0 I7 p- K6 T ;/ c8 ~# Z p+ W& K
OpenCmdInCurrent()
& r. r$ m# `$ x {8 B* n' g3 j$ z: m7 m5 ^
; This is required to get the full path of the file from the address bar$ }/ G4 p" k2 f
WinGetText, full_path, A
8 }! j3 X$ }% `1 J) @ ; Split on newline (`n)
3 A* X& B8 w( x& ^ StringSplit, word_array, full_path, `n
. v" M8 Q! G$ j2 C _* E; a/ } ; Take the first element from the array; x- E7 o! `0 T0 J
full_path = %word_array1%" p+ Z Z# Y1 R: |: x# ]/ [" ?
; strip to bare address: I w9 p# K% L0 F: J' w
full_path := RegExReplace(full_path, “地址: “, “”)
1 r* \2 E: ?3 n5 O ; Just in case – remove all carriage returns (`r)" ]9 K4 U2 W2 l* S1 W
StringReplace, full_path, full_path, `r, , all; t# l, w) c% U% i. g
IfInString full_path, \5 t) C1 l1 j5 j# D( |* ?
{2 x! E$ P* h, [* @
Run, cmd /K cd /D “%full_path%”
+ A% s S: v8 x- B7 b }0 P. M! v n B# p- j4 `, P! {
else
4 B1 J0 s* N3 x v9 z9 ] {$ z9 ^) ?5 f4 l: x* D
Run, cmd /K cd /D “C:\ ”
9 }% {. h0 `, }" M, [ }7 `/ a+ ]: v* j6 I6 {
}. \7 U; G) v5 j' s; r% x! m
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
) W8 Y# |9 [, R; k( @# n5 k 这段小代码肯能有两个你需要修改的地方
+ Y8 E) C& J! i+ {& s4 Q* z" N' { 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& [8 Y6 A) q8 c2 A
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. b: t$ H4 k: J1 {6 V' [' { |