此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 V( F/ n& B6 Z# c 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 j. q, N8 j# T) [: u6 i 方式一:, C+ E9 T: B9 Q
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# y) `2 _* g: C. S* a; A
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
* \. i, P6 k. ^ p# Z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 Y/ F! o5 k, T
方式二:, S; e4 Z; |1 d% I- H5 R
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 }/ H1 Q* p n% y q) j SetTitleMatchMode RegEx
& L( u. K Q! j return' ]; I% K. `! u0 S$ F
; Stuff to do when Windows Explorer is open
( b$ F# \0 Y1 P$ I4 @! d: d( X6 E ;2 l5 W4 U/ ^/ X2 v/ J3 j% N
#IfWinActive ahk_class ExploreWClass|CabinetWClass
% L) u1 T/ S* g' C7 Y1 L$ { ; open ‘cmd’ in the current directory, r6 u! A% l' V2 N4 z$ b9 g
;
; g) R. V6 w( V, K+ j( r$ t( d8 c #c::
& t$ C$ K! r8 u OpenCmdInCurrent(): {$ G5 M* }/ N8 T) ]4 K9 E# r
return
1 K7 L, p5 C9 H #IfWinActive8 N: I4 v8 S# G, I* v
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: }/ ~: E8 p6 |" `% q& q6 _
; Note: expecting to be run when the active window is Explorer.2 V: K) H2 P* W
;
) p: ?5 a& j( I: H- `* x1 O) Z; E OpenCmdInCurrent()
/ E# W: w; \/ L7 L$ e7 M( e; I {
6 j4 M$ Y) W) m; R, Z. k ; This is required to get the full path of the file from the address bar0 I# e9 |! ^/ V; K2 P P4 m
WinGetText, full_path, A
( m( ^1 |$ D5 u2 Q3 ^1 T8 U ; Split on newline (`n)& d0 \/ M9 x) `
StringSplit, word_array, full_path, `n# `" z# I3 f) Z' y, Q
; Take the first element from the array
5 ^8 J$ F7 K: f2 ?! s2 @9 _ \ full_path = %word_array1%/ O5 O/ N% z5 O% }' T
; strip to bare address) J) u0 y6 `/ k. A- F5 p+ G+ G7 V. ^
full_path := RegExReplace(full_path, “地址: “, “”)
6 o! h6 q0 h6 F E" b# w/ l ; Just in case – remove all carriage returns (`r)
K V) C0 ^3 r6 c q& _ StringReplace, full_path, full_path, `r, , all
! L' _1 u: F" }, f1 o, l& u$ A" S IfInString full_path, \% d+ L. k% f; M. [, M
{& R! `$ Y% Q# j4 y
Run, cmd /K cd /D “%full_path%”; d7 @$ W$ }9 e7 U: o$ S
}" b' v' H7 [, p+ U
else
$ K T# i' |1 o( ?, x {! W1 z7 p6 `3 {) M
Run, cmd /K cd /D “C:\ ”
I" m+ I1 ^) g6 _7 }8 Q }
* J( f, a. j1 | }
8 N! L, k* E V9 s+ M7 F; x5 \& _ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" y- {2 B# w8 m( p- W8 ~
这段小代码肯能有两个你需要修改的地方4 E# P0 a2 `5 q2 j% t( H
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
: q9 S! r. n! X7 Z: V 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
6 g# t3 u, Q: t( k/ I$ T |