此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) s8 S5 p( O2 z2 x$ _
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 C) Z$ C5 Z$ `8 y9 U& c9 t: |
方式一:
- c! i) j9 g1 U7 z6 r+ U 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ E' t, J- I3 V2 S B# U: C9 q- Y 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# T2 i2 H% N) l
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
0 h. [; X" x# c' d1 F$ Z8 u 方式二:
* \0 u) ^8 u: t) Y# A 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:0 a% Y u7 \: v. y
SetTitleMatchMode RegEx1 {7 M4 @8 ]- ^4 q7 e
return. s% f& F5 U* f3 }6 Y* E
; Stuff to do when Windows Explorer is open
6 m$ \8 O. t/ A' E ;
! U* \$ P) A$ ^3 }% ^! l& p #IfWinActive ahk_class ExploreWClass|CabinetWClass) J" }8 h6 e# K M. M% z0 p y6 p
; open ‘cmd’ in the current directory
# J$ ~- Q+ o/ ^( h ;! Q& ~& b& a' D- E- z4 `
#c::3 c# d( a/ F9 x
OpenCmdInCurrent()
5 K$ E: q9 b2 v0 g Q _ return* y* ]9 i3 d, a( D& L2 i
#IfWinActive( Z% s# `0 ~- U
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( i5 d; ^* ~9 W4 g [2 r' W1 x
; Note: expecting to be run when the active window is Explorer.
* c; @' {$ t5 ^6 g1 ^% B( K$ S- L7 @ ;
' U5 G' y) M5 C: B$ [1 v( k OpenCmdInCurrent()/ A2 m' {0 d& ? S% @" s3 p) L
{1 f8 h3 }+ J( J' y- N
; This is required to get the full path of the file from the address bar
9 a& ~" I% y% ~7 O$ q- K WinGetText, full_path, A! y: z* B( `; E( Q2 H) w7 R9 @
; Split on newline (`n)& y4 ^7 ]1 O+ U$ P& \
StringSplit, word_array, full_path, `n
' a% G; Z9 o' j, X9 ~3 _5 t ; Take the first element from the array
0 M; q; x0 `9 s! U* N! y full_path = %word_array1%7 _2 \' q5 M* d: i+ q) }& a
; strip to bare address
! l. H5 S5 |- ]$ ~$ D full_path := RegExReplace(full_path, “地址: “, “”)9 B }: ], i( k
; Just in case – remove all carriage returns (`r)
# R8 l' e9 H2 ], _ StringReplace, full_path, full_path, `r, , all. _+ `3 P. o/ v& f
IfInString full_path, \
' K7 k: d3 k8 h {8 d1 v5 o6 C. s% t
Run, cmd /K cd /D “%full_path%”7 \+ f6 g' ~7 n4 T9 Q8 T$ b) y
}
h; p9 n6 F: R9 c9 d" A else. ~; r0 P c5 `! b3 _
{/ k) Y6 C4 n' ~! U. k2 @& Z
Run, cmd /K cd /D “C:\ ”
; j& Q9 M( P/ o [4 g$ p* q }
) J2 O7 T! h. U3 S: H* m }
% ~2 o7 E% L5 R7 c( t( E 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 e* R3 _/ J( J2 r! w8 k. I 这段小代码肯能有两个你需要修改的地方
; C. _8 D: f- [( r 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键+ x0 P" N1 R6 c* N7 U
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “* v* {7 d( G$ ~/ q( J. R. T; }' ]
|