此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ X7 m, V' a5 \$ ~0 c+ ?2 L& ^$ Q
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。( f8 R! z& g" c( K, M+ M
方式一:% S% |' F9 B$ B4 l6 g) ]2 I2 I
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* k% b& F' W5 p. ?9 f/ l 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和2 u. m5 |3 J% {9 e/ y
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* C! P& o: ?9 W0 v: r
方式二:
8 Z* B% M- B( Z$ a# k 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 n7 M+ w# \7 |4 S! g/ X, q& E6 h
SetTitleMatchMode RegEx- j9 J. d4 J1 H: K/ k9 [; R: C
return& _8 x2 o; ]$ c l; M
; Stuff to do when Windows Explorer is open2 I9 U; f+ Q9 ]" M9 q$ E$ u
;
! l4 V c! N/ D/ r. v# S4 | #IfWinActive ahk_class ExploreWClass|CabinetWClass
7 x7 D; e9 x0 I( I$ H1 m2 D6 J) Q ; open ‘cmd’ in the current directory: o4 |0 A4 S" V6 D3 _' |' t
;
7 v5 R9 a6 ~8 ^) f$ z #c::
3 o& S7 x3 u) l1 M. ` OpenCmdInCurrent()9 b4 `# h$ M( q+ B4 _. c% I
return
I/ I, K- n5 {* n #IfWinActive4 v' ]! n' D" u! d7 J
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
" d* q5 R8 U4 ~( a H/ j ; Note: expecting to be run when the active window is Explorer.
$ F' v$ O, P, J" B ;- b! v9 `1 G0 z: L2 b5 `9 y
OpenCmdInCurrent()0 N3 e. Y5 i' a7 q7 a- f& C7 d7 ?
{5 P7 @- N1 u4 t+ F& J) T/ b
; This is required to get the full path of the file from the address bar: V* a6 g, z1 q0 i" J* y9 m
WinGetText, full_path, A
) [2 {& y7 d4 c6 D' w6 r ; Split on newline (`n)9 u- `+ x2 z! H, b; X$ U! E0 _
StringSplit, word_array, full_path, `n5 p% i4 G$ ^' d5 L! s, [
; Take the first element from the array
) n! b- X! F+ d) s full_path = %word_array1%# i+ M- t% d7 D1 ^7 B! |
; strip to bare address
7 G& n3 V/ \; J2 h% i, l& m" ~ full_path := RegExReplace(full_path, “地址: “, “”)
$ h% O, x. a& @/ m4 k% a5 [ ; Just in case – remove all carriage returns (`r)
+ J m* Y! Z3 y9 n StringReplace, full_path, full_path, `r, , all E5 E/ \& }* Y# v! m
IfInString full_path, \
/ [ R: Y+ q; ~! c+ C {
, @% F% Q4 k6 x4 K2 H ] N Run, cmd /K cd /D “%full_path%”# y& E4 H* v( }7 B. j2 o
}" i# V: d( G( G
else
2 c: Z' W8 s, N" O! \5 ~ {' p$ {% Q+ f/ z' I+ e# z
Run, cmd /K cd /D “C:\ ”0 P$ k# _9 N1 c7 f
}
4 b- h2 p9 _# p" c1 Y2 K }
! B9 M! ]9 w' [ G, O 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 |/ \ M" A0 \; A4 E4 |
这段小代码肯能有两个你需要修改的地方" Z5 A( g+ l. E
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( _3 H* W* b; C 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ J' @$ y+ U$ G% K" E# V0 \ |