此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ L i$ S q! _7 X, i+ Q
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 q( Z: }" e; f& _( Y7 w' {- H
方式一:
1 c6 G/ \9 ?$ s9 A' L 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
8 j- {. q; N' r3 k 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, `! @( m4 m* P, I( B9 C& N HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。' d7 X4 C' M8 G/ V4 q
方式二:$ d" @6 N4 _; O; e V& r# j$ P, h
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; V+ H) z2 V( t, H! D( F1 i, n* A SetTitleMatchMode RegEx0 T& q, g# c$ l
return1 n0 b7 i; {& @ J
; Stuff to do when Windows Explorer is open. j! ~, K8 r1 c; j
;
# j& e6 V2 [2 Z #IfWinActive ahk_class ExploreWClass|CabinetWClass/ N' X" F5 N& x- X: j3 S
; open ‘cmd’ in the current directory. x( ^. l5 q' Q, ^
;* j0 B" S+ ]! t @
#c::! V8 a6 r- S0 Z/ L% ~1 e
OpenCmdInCurrent()
- B. Q! Q) @0 h' z# h* A return0 I# q8 l7 ~) }, H
#IfWinActive
4 x0 y% ]$ V* h+ Q) G! P8 s+ t ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. c7 P$ P- o c9 s+ i9 r ; Note: expecting to be run when the active window is Explorer.
+ k/ I4 T6 t: u9 s ;
% o& I7 Y+ q& O1 A9 h OpenCmdInCurrent()) t, q& m1 i, T4 e* P) x
{
4 j1 J- h7 h* V1 M' J- { ; This is required to get the full path of the file from the address bar4 W! H* }) J: V+ n
WinGetText, full_path, A% f7 S" Z% ~$ q) w$ Y
; Split on newline (`n); F' ]8 w: U1 }9 `2 ~
StringSplit, word_array, full_path, `n
0 \! m! I, U1 x7 e* C& e9 R3 l ; Take the first element from the array
! E& K: _& ?; `! b, h full_path = %word_array1%
6 h7 B. `# P8 V9 s. I ; strip to bare address5 W" T" D. W4 h3 W6 U; l+ U
full_path := RegExReplace(full_path, “地址: “, “”)7 o3 R0 Z$ ?, y5 s* R6 T" M& D
; Just in case – remove all carriage returns (`r) i' F$ m: w& R# z U
StringReplace, full_path, full_path, `r, , all
( t8 e( g8 T. G5 ?! e0 o d! j$ g IfInString full_path, \: }0 n/ V3 g2 l7 s& \' @% Z( D
{' i- Q; o' L z
Run, cmd /K cd /D “%full_path%”
0 S- P% O, r$ ` w3 g2 v; [, F$ I }( c9 s3 h! N: n8 Q; X2 g
else. `! k" m/ D9 y9 G# d1 N; C
{
t3 A& C, ~1 n" g- S8 }* s: U Run, cmd /K cd /D “C:\ ”
. d0 [$ P' F0 D }
: K! H5 Z' q3 v D- B- u# X }
" s1 G' T$ ]9 Q5 b+ _& n 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- i+ R0 N7 S- s6 F 这段小代码肯能有两个你需要修改的地方
/ r- C( I3 |# v$ _2 V3 x, r5 N 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键8 Q* @; v* @% ^2 m1 `
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 q, R& g6 u! D! R" E; a
|