此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: X, L8 C* Z+ I7 t9 r9 L
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, \/ h; B3 E6 x3 ?3 ?) E T, j& X 方式一:
+ i( S" k8 c( O& }% R4 l. ^1 h 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# h; x& h: _8 a, j( o! Q9 N 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和4 \& {& b6 A4 M/ v
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
. d6 v7 |. W) u 方式二:
8 U0 F2 |. }: F6 j7 L 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 r$ v8 c/ J7 a
SetTitleMatchMode RegEx
4 b% o2 w8 z' H" \$ {; b return9 A2 x" g6 B k; k
; Stuff to do when Windows Explorer is open5 j7 @* j( E; q2 _
;
! ` I! M& P4 K# _* g- } #IfWinActive ahk_class ExploreWClass|CabinetWClass) H1 m. d: u8 T0 y# e+ D' H' l
; open ‘cmd’ in the current directory3 q% O t3 b( `+ [& d7 d8 }) R
;3 E8 b* I$ R0 n7 J* D
#c::
6 G. c) Y/ C1 t6 D8 W OpenCmdInCurrent(); V9 q8 o+ |7 k' C7 N% b3 U
return, u) D- n1 N$ y+ c
#IfWinActive
/ m4 H; ~# G1 c2 ? ; Opens the command shell ‘cmd’ in the directory browsed in Explorer." m. b" D' X: a2 B7 e3 h1 H+ S
; Note: expecting to be run when the active window is Explorer.1 n( Z0 n! l- D( O" q7 o( w3 d
;
, X) @1 g& T" p3 d) ^8 Q OpenCmdInCurrent()
* E! p" P9 D. S' e {& A7 {! I a( o. q1 B; x
; This is required to get the full path of the file from the address bar5 l& s& }/ v4 p
WinGetText, full_path, A
: Z- \# c( `4 K! x7 [* { ; Split on newline (`n)5 D1 Q2 w3 s4 }! A
StringSplit, word_array, full_path, `n; f3 R+ q3 u# M7 a' k
; Take the first element from the array
2 a1 F' Z0 y! w* e9 S7 \% \$ y full_path = %word_array1%- w; b' _1 n+ j0 I" d+ Q) ^+ K
; strip to bare address# E$ B' L/ @+ e& H& H) ]7 R
full_path := RegExReplace(full_path, “地址: “, “”)0 R- J. @" `! G K
; Just in case – remove all carriage returns (`r)
8 }# q; R x3 [ O! o2 G StringReplace, full_path, full_path, `r, , all
. P3 g' c$ n* }. o+ r IfInString full_path, \
! I% E+ `$ l$ ~$ V. i6 O# f {
; ^* l; ~+ f! l/ Z2 S$ i Run, cmd /K cd /D “%full_path%”! `, G; [0 R) M- U, G
}
7 q# D1 B. M9 r: P& W# \9 | else6 l; c$ Y2 X R/ z: `; s
{9 s! j# R6 y8 {8 f, w8 f2 H7 e% a
Run, cmd /K cd /D “C:\ ”( z# {4 Z4 y5 p1 j& d* P
}. I1 F" H3 E5 y
}% s- H) c$ u& C u4 G0 u0 |1 ?8 M: L% w3 P
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。# ?" ?# B$ T+ ^( [2 d
这段小代码肯能有两个你需要修改的地方; y3 i+ L9 `: i9 N7 q, v
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键: ~; N* Z0 V7 j
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; q8 g. o8 H& M" e" \9 D7 o |