此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ t' W- N+ U4 G7 ~ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。# `+ L9 A$ w; }( \9 Y/ `
方式一:5 T4 ~* A7 U8 U2 a
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 |- ?: |9 x9 v3 M" V6 o 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 \5 i; D# o4 V) u- L: i+ T HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
. G8 ~3 p" |3 F 方式二:
" g* c' Y! x" s) M3 u) J7 n 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 a: d7 Y( u+ y4 v7 R$ _! [& @ SetTitleMatchMode RegEx
- ^# d) ^4 p. b- |( Y0 } return
_1 o: n% k2 r8 a. m: C7 i ; Stuff to do when Windows Explorer is open& |9 }" O3 m! i0 {
;
/ W* S. J6 h2 M* Z) w, a #IfWinActive ahk_class ExploreWClass|CabinetWClass2 U2 h7 Y d" O7 B
; open ‘cmd’ in the current directory2 ^- O6 X9 v# K
;8 U/ w8 R' c$ |2 {9 X4 }! ]
#c::( \" M1 @* L+ G- y6 H! {+ Q
OpenCmdInCurrent()
% ^) l) G% F# {) U3 a& v% L return( h% w: u2 T6 ~( F% |
#IfWinActive) D% B. O2 V- Q y1 h6 v' f [
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 O8 B/ J5 p1 ^ ; Note: expecting to be run when the active window is Explorer.# x+ T6 s- g8 p% N- Z
;
. y$ Z& {5 S. i4 a4 Q9 p OpenCmdInCurrent()
7 S [* N6 `& `' a j# H, o {
4 K# J; H' O2 p8 i ; This is required to get the full path of the file from the address bar
0 p/ `3 g1 V' t8 ^ WinGetText, full_path, A
# C" N7 I* ]* F$ s9 v ; Split on newline (`n)
1 e% l& k- ^+ A+ e. d StringSplit, word_array, full_path, `n; ?( |2 f: W" W" i
; Take the first element from the array
8 d1 n3 i: C' F& l; _ full_path = %word_array1%6 q! D7 w0 f3 ?& b+ Z- l
; strip to bare address
& ^; _. ^! d' g6 U. m: \: p full_path := RegExReplace(full_path, “地址: “, “”)
/ b4 c+ r, d" { C' }8 m: w ; Just in case – remove all carriage returns (`r)
: a/ }! o; j' f d0 n2 U, B StringReplace, full_path, full_path, `r, , all
; N9 Q9 I* j5 X Q IfInString full_path, \0 R& e$ E+ Y: e5 I5 G" P- X
{
% x% S7 I+ q7 } Run, cmd /K cd /D “%full_path%” p1 r! p/ g7 O* D( A, n0 I& U
}/ ]* C4 L8 H+ X5 Z) e) ~2 ~
else
1 j% O& f8 h& y/ i4 g+ J4 [" m. G {
2 Q8 t1 J/ d" t Run, cmd /K cd /D “C:\ ”: w; K1 \: [9 i* a/ G
}+ K2 I7 K4 \8 v; ~
}& ]- ]8 W2 c* A: b1 s( p
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 k! e/ L4 Q% `" W; a4 p) E7 p/ Y$ b 这段小代码肯能有两个你需要修改的地方% K2 d C) s( u+ K/ g
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 v! ^9 `! h4 @. P4 v8 l9 |0 u9 t 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. U5 L, w0 p9 z, g2 |* I+ ]' ]3 p |