此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
|( l5 p( I( v3 v8 S& W 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 E1 y! E. S; F/ l2 ^ 方式一:" K' F0 S. R% N
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 g$ s2 c h( {/ A+ F+ l7 _, M
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
+ S# e( ~: G. M5 `9 L+ T. R HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 y; F0 `7 V4 [" } 方式二:
: C7 i2 W1 T% u, G 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" G# G. J3 y, U SetTitleMatchMode RegEx
( d7 b5 V3 |3 P k v. Y6 o3 T" |* W return% h9 h* X& h$ x- S3 h/ c
; Stuff to do when Windows Explorer is open+ L; [1 @* E1 U
;+ k7 \1 |% z: U2 j5 C+ F* m4 u% G0 D
#IfWinActive ahk_class ExploreWClass|CabinetWClass
3 @# `/ ^8 G. Y3 a# _3 G ; open ‘cmd’ in the current directory) O' ~8 r8 s5 h h
;) ?" @4 Y. I8 q# R/ l' Q
#c::
4 P7 ~( T+ s' e6 Y OpenCmdInCurrent()
% H2 t7 Z; y0 [1 i5 U7 H return7 Q+ p w9 n% l+ _% n1 C1 X% [: B
#IfWinActive
1 } P( t, ^% h' w2 Y ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
! F" [9 P# F; ?! y6 A ; Note: expecting to be run when the active window is Explorer.
$ x% X! m x6 n ;' B0 K# X* _" B6 U% t1 u
OpenCmdInCurrent(). Q& m, P0 t; e, y |6 D( d: Y
{
7 e& C9 H* e$ Z8 ] ; This is required to get the full path of the file from the address bar
8 x+ L6 f* X6 }) y* p WinGetText, full_path, A
9 x8 p" L- w; w" _' u& _8 E. c5 T ; Split on newline (`n)
$ u, Q% t0 ?- }7 E! ` StringSplit, word_array, full_path, `n, w1 K) f% p1 }$ P9 c
; Take the first element from the array
1 ^( W* A3 @* b3 S1 J$ S2 P' ?, N$ _ full_path = %word_array1%2 `* b$ ~3 n/ S
; strip to bare address7 ?2 b( l4 u+ r$ H( j( {) c
full_path := RegExReplace(full_path, “地址: “, “”)
4 x. j; U7 M- q7 V ; Just in case – remove all carriage returns (`r)
], E( D" Q% F5 y StringReplace, full_path, full_path, `r, , all
% N0 [+ i! y1 K- S# ]" q IfInString full_path, \2 {+ y+ y% O! S: @+ \' d1 U
{5 c% S! B& c" L- g
Run, cmd /K cd /D “%full_path%”( [) T( }1 I0 @, a/ I; z
}, {4 H: F$ `( Z) @; w1 ?% `
else
2 |. E0 g& c* O, R" p" E {- j' j$ Z) g6 j) E- o
Run, cmd /K cd /D “C:\ ”+ m" E+ j8 a: Z' q4 {* m% V& {6 J& Q! ]
}
# ?% M! _" ?8 y& j$ x# N }5 K( F8 A% u, e
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
% b2 _# Z3 o) Y7 x( } 这段小代码肯能有两个你需要修改的地方5 k" r3 _7 U1 d7 b! k: |* [
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
X) h9 v5 \# s2 A! a 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
0 w) `9 `7 o3 ]' H# [2 d2 h! R& q |