此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 w; A3 K# m8 V0 U! o
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 ~0 j( J( w% m% f$ C* Z1 J
方式一:
9 T' z: _, [* x6 F. {$ d 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
. R' h' ^. _7 T u% p; Q 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和( K2 f) i! e8 T( g* U
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。% r4 U7 F+ A5 ]# f
方式二:
& Q* X: L3 T: h' x 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 f" s! y; l+ s
SetTitleMatchMode RegEx, K( z) W% R9 f" d
return
\+ |% ?" t; n ; Stuff to do when Windows Explorer is open
5 ]+ g l3 y; {4 n, S) d ` ;
- m3 \ ]1 E) ?, Z #IfWinActive ahk_class ExploreWClass|CabinetWClass1 z# M5 _/ p( v, x
; open ‘cmd’ in the current directory
1 i- A! `* n8 n: W$ ~ ;, i8 s1 }8 S% g
#c::; D0 O; \/ Z) h( w! @
OpenCmdInCurrent()
- X/ _* x# @/ ? return5 m& S- f: T; g( r" U" `
#IfWinActive
* s/ {9 b9 B* L$ J( \# J ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 i7 x/ L& t2 S/ m5 E; }: G ; Note: expecting to be run when the active window is Explorer.
2 O+ [4 G5 a3 L ;
5 A8 U; w% |* O OpenCmdInCurrent()
" m% D' y. w% q h5 f! n* o {
( k: W% {7 D) l+ m/ m' J- y ; This is required to get the full path of the file from the address bar
+ \# w5 X* R5 k WinGetText, full_path, A
7 D6 x* u+ F' s8 Z& Z4 X5 d ; Split on newline (`n)
% q# f) y: {% T/ q5 F& S5 ` StringSplit, word_array, full_path, `n6 S0 @( K6 K9 F% P
; Take the first element from the array. q( B! k6 L3 _5 I4 J
full_path = %word_array1%
* w0 m0 R1 [( H4 z9 s0 u: _ ; strip to bare address4 M, f* p8 z ]0 c- @3 ?- d
full_path := RegExReplace(full_path, “地址: “, “”)5 W& U. N/ q* Q5 f
; Just in case – remove all carriage returns (`r)
; [; f+ P B4 {2 t. d2 a StringReplace, full_path, full_path, `r, , all
' `; w J& v, }. ?" B' Q# I IfInString full_path, \, \0 L2 B; j: f9 N" P$ L" @
{( x1 i) u1 h" T! `7 K
Run, cmd /K cd /D “%full_path%”
4 C+ ]; S! g7 u) ?. ^& j6 |4 C6 e7 C( k }
1 d. T+ z# \9 y' b else
; Z' Y5 U& I5 q7 }9 L {3 B( Q' V7 g- I3 p& i! o8 x8 T
Run, cmd /K cd /D “C:\ ”% x* m& v" R% a8 r
}
+ p9 z s, n/ ^: D& d" f }7 x& s! c, z* i
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 z( h* g6 n1 r3 S' ~2 y1 Y- b 这段小代码肯能有两个你需要修改的地方; l1 T0 T' |/ Q6 V9 m7 U
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
l5 V; o4 u- a; z- H( Z: t9 b. A% Y 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. C# N$ | l1 ]
|