此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) S; f9 V$ W) S0 D) t% {- B; b
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ R0 D/ ?1 z$ i4 A% H
方式一:. L. K o& [" A
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# v* D7 T* }. O9 _- N1 j7 a
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' ?, `/ u% r6 K$ e7 S" t4 b- M
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( K, I0 x3 q3 _8 z
方式二:
5 U4 m9 h5 B# o 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
: R7 \9 z" s4 _4 { SetTitleMatchMode RegEx' w8 W9 d1 l4 n
return
/ f% G/ {" I6 \ u% y0 g; v) T ; Stuff to do when Windows Explorer is open. @1 V$ r8 W, c3 d {4 A
;
1 Y. ?0 j" ]. | O5 u0 Z #IfWinActive ahk_class ExploreWClass|CabinetWClass
; w5 L; P" \% t9 A ; open ‘cmd’ in the current directory
5 ^( l+ u! p2 N! I8 b1 N( ]1 g ;
# ~2 |9 J& Y; G$ x #c::( V" k) J6 U5 A4 o5 R6 F2 }6 x
OpenCmdInCurrent()3 a: H) _. |8 _ j5 ]- H1 Q
return4 j$ L) Z* j1 U& s% N5 g+ s
#IfWinActive
8 t7 R9 [1 b4 z1 K' q9 w8 w ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
! [' a r( X2 m" ]2 `9 L- W ; Note: expecting to be run when the active window is Explorer.
( ^2 ]) K! z6 O2 m9 @3 ] ;
! {5 v9 z$ b) `: [% E. n OpenCmdInCurrent()" R! w( y& p A- J
{
- B; j* V. e. m& @0 b2 W+ m/ R ; This is required to get the full path of the file from the address bar- I/ d8 K& T6 Z' j& t, O
WinGetText, full_path, A
) y$ W P- A) V ; Split on newline (`n)( i* X1 ^9 G# a, A! R
StringSplit, word_array, full_path, `n
9 S7 @ n4 z3 K: { ; Take the first element from the array2 M( O) T5 k$ v9 x# O, a" a
full_path = %word_array1%
4 u+ l8 u% t0 j, P1 @. Q ; strip to bare address
! X' a9 l W+ Z2 u$ ~3 @, K# m" X full_path := RegExReplace(full_path, “地址: “, “”)
* h( q" |- h% ?/ `3 ^ ; Just in case – remove all carriage returns (`r)
7 \, O' |2 P5 E# f+ r# A5 q StringReplace, full_path, full_path, `r, , all
8 g4 L, O. `: d$ y( P0 a: Y) E IfInString full_path, \7 J* _+ V- _/ w: a8 n
{0 c3 e' ]7 k% j0 `% }
Run, cmd /K cd /D “%full_path%”! k3 i( j+ ?. P& m5 k
}
; { [# `& z5 b) Z else
" v4 i% {/ L1 H4 L# A; o1 e" I! c: U {
* Z% H) z- i0 _% _ Run, cmd /K cd /D “C:\ ”- j9 P0 { q" z; {) y4 O& p/ P
}8 t! g3 U% h0 P/ V- h
}
* M/ F7 f& Z% s T. u [& Z 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' ~" V" |2 ~; W7 V/ D
这段小代码肯能有两个你需要修改的地方
% h" X4 [1 c6 J 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# P3 e8 o5 |8 f; R( d8 M 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ ^/ s5 g8 ?2 i% z/ \- Q' g1 E# Y {
|