此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
* a0 A$ ^0 ?4 W7 ~' w$ t5 r- u 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
' d" n* G" Q3 @/ i8 N 方式一:
/ |. H6 r& z1 U, \" \2 ^ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 h! X: R( S/ {# X$ i
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; m# W; E! f; ]) z" V1 ? HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 P( J0 V5 Y- F- g# E( V+ x
方式二:3 Y p+ H: \. ^( L: _+ e. I
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; y. m, b; m* L. j; y/ k) h SetTitleMatchMode RegEx1 l9 M, g+ r# j. J; t# a
return9 g( S( X: y8 F9 T
; Stuff to do when Windows Explorer is open8 X" U/ @. n' t# g; p# S) j
;" ]) T* ~* l* s& }& {# R [
#IfWinActive ahk_class ExploreWClass|CabinetWClass
% R ~: g3 j3 }/ ~/ L& i# n ; open ‘cmd’ in the current directory
, \5 k6 G+ [2 [; A$ C, u1 H ;
) m# s% \% f7 K/ m/ | #c::
0 {& n. }2 a7 y1 v OpenCmdInCurrent()
. v" U6 Z& v3 z return( M/ x. u( P8 D+ `/ e+ W. A
#IfWinActive; N" F4 Y- {& {# r( g
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 E" U6 z( i; R" \ ; Note: expecting to be run when the active window is Explorer.% G8 j/ y# E6 p$ A& B
;
' K G8 S% y* w" A OpenCmdInCurrent(). f4 |8 o) e& H$ z+ t3 w
{3 s" K/ \/ W" z; ?
; This is required to get the full path of the file from the address bar
. K3 T2 @+ s% n w. j5 _2 b WinGetText, full_path, A
4 E$ C" ]) S$ ^$ C2 s) p. C. w' { ; Split on newline (`n)& l& j {5 B) Z8 k" z5 u
StringSplit, word_array, full_path, `n
; N1 j8 c0 W$ j) P ; Take the first element from the array$ D- z1 I3 l$ z6 C* I3 @
full_path = %word_array1%
9 g( R7 v" J1 l' n, W- Q1 O7 e ; strip to bare address
0 b4 R! D. M( |. v: }! s8 I1 n, Y full_path := RegExReplace(full_path, “地址: “, “”)
* R: v3 b8 l( [; R9 C+ N ; Just in case – remove all carriage returns (`r)
" Z$ }1 l F& \ StringReplace, full_path, full_path, `r, , all
: ~7 ?$ ?5 ?$ ^ IfInString full_path, \" A/ g! z6 `4 P# b& @8 j- @$ R! Y
{7 ~1 K# T. o- [" Y) \6 W& t: y$ B
Run, cmd /K cd /D “%full_path%”
! z) k6 Z( j' C' W' O }
; w5 T4 d) Z! x0 U else
* j) w* L/ P- j# U+ `3 b- V" ^ {
$ S$ A! q% P) }; Q0 }0 t; m Run, cmd /K cd /D “C:\ ”
. t7 h3 J- `+ v' B. o }6 u' w F* g2 w R) ]
}- c( @* ]+ y7 r- c1 s
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( I( V7 X/ K+ s3 f. ]
这段小代码肯能有两个你需要修改的地方
$ X* F% ^1 N' I4 Q 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 o) [: J, h2 I- N! K2 N 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! _, ^, G3 B! W* I7 y8 W
|