此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# L7 x( K l; i7 S9 l
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, E+ d/ h- o: e8 @7 [1 m& T9 \ 方式一:. ? J; F3 Q% V
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 ]0 o/ {6 ?; Z# c& S% s
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
& Z( a, m0 e4 f1 v3 K$ I' M HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" ~( G, t2 b- m- |4 S# D! ]6 w7 C, q 方式二:0 X; P3 V* m0 P/ b% N9 s
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 q- f/ a7 H, e
SetTitleMatchMode RegEx
- l: U8 A S' ~* ^ return3 N% J' [$ \$ Q
; Stuff to do when Windows Explorer is open
% H1 A# J! Z$ w. X- s0 w ;
4 @* j) r3 Q/ d. O #IfWinActive ahk_class ExploreWClass|CabinetWClass0 P* C* |6 ~! J9 f) {; s+ w
; open ‘cmd’ in the current directory: Q; |2 o( F) P: H ?4 D5 K
;
! E+ J! h7 j3 I+ j4 e7 B #c::* _1 i2 I. Z6 V- S% \/ T
OpenCmdInCurrent()5 D' h( d6 M1 W9 v- e" N% G
return
1 _/ B5 f7 U# z #IfWinActive
1 Z$ {+ T, {4 X+ T- Z! l ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 N/ a+ ^3 U9 s+ f( G+ t% s. M
; Note: expecting to be run when the active window is Explorer.6 T7 o3 h3 f$ O, ~3 N9 }& H
;
9 j$ ?/ o3 S- L; i8 D. n OpenCmdInCurrent()
! y8 P& g* t8 c z1 c {" c5 n, {) j9 R; |- G
; This is required to get the full path of the file from the address bar
; K5 @0 L# x/ E/ |) k9 H WinGetText, full_path, A
6 G0 b" m( z* p5 J( X+ G ; Split on newline (`n)
7 `2 L* Q) o* }2 |1 S StringSplit, word_array, full_path, `n6 Y2 D* P+ o& v, k! Y) C
; Take the first element from the array
f: k% S/ C* X full_path = %word_array1%
1 H h" D1 |( y0 w3 l, z' j ; strip to bare address
8 H0 l# k. V- J G' u- H full_path := RegExReplace(full_path, “地址: “, “”)
3 H' b2 J4 i. v5 ^ ; Just in case – remove all carriage returns (`r)
6 T8 @$ i% j9 m$ r! U3 ~0 x# s StringReplace, full_path, full_path, `r, , all& M3 J$ X- {% ^" n S3 G- X! ?
IfInString full_path, \
9 a( `: s, R7 F% I4 q9 X# U4 F1 y: K {
, M$ Y, p1 a8 N) y0 A! @/ H8 r Run, cmd /K cd /D “%full_path%”
; W8 ~4 T' F: K' U4 }! |" G }
1 D7 ^, W5 v" e6 _8 a* S6 j else
2 w1 f \) y. f; T* X {7 A, U9 M" l( y
Run, cmd /K cd /D “C:\ ”
" C# \; X' Y h/ Q; T b }
8 z' y3 a, u% F/ D! Q3 ?" t/ D }, `7 k8 Q, |) l6 b, S/ D* T
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' y* ^9 Q" Z0 [- o
这段小代码肯能有两个你需要修改的地方9 J+ k* D# S+ h
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
2 h: n0 n h2 N* O" i {6 n 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “" w# ]6 R% @% X( ]2 o
|