此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
4 L6 Q) a7 K( W; Y) q; x 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
6 r$ n$ @. F. U- ?# g 方式一:/ x3 {! v' V) i
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,! i8 l, F% ]# L6 x w! b+ M
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! j, Y( \) J; S
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& ~3 `" [. i' Q4 X$ Q% K9 S' d 方式二:
3 C. o3 w- k2 [ l2 m) h+ M 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
9 l) c5 ]+ G$ H$ ~ SetTitleMatchMode RegEx
3 z+ X4 H0 u9 q1 N! K6 u return; t4 a, D( Q X" b8 U# v
; Stuff to do when Windows Explorer is open
" S9 }1 ~1 }% [ A) R5 ` ;
4 Q2 i2 g1 l# b( c. r! o! c #IfWinActive ahk_class ExploreWClass|CabinetWClass6 x6 s$ d9 W; y6 V* r2 c
; open ‘cmd’ in the current directory
$ w- I6 A4 h8 v# D ;
1 S& k* r+ f7 {. c0 @ #c::
2 P) D8 }3 v) l" y5 p5 b OpenCmdInCurrent()
! W0 N) H5 F# _% T' E return
. y0 s! ~* d8 V0 u' M #IfWinActive
& W0 ~; o- P, g5 m1 p ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ _6 P- V: q! q% o& M) c# C: o ; Note: expecting to be run when the active window is Explorer.
0 k+ A; W0 ]. ?6 H, P, z9 ~ ;
# r6 u' H' @$ Z) I OpenCmdInCurrent()$ F" R. U2 X6 A; M$ H$ j: `
{% v. \' J6 x! s# {7 s- G7 b
; This is required to get the full path of the file from the address bar+ d' p* V y" |
WinGetText, full_path, A' n* X! Z* p1 Z7 q; _
; Split on newline (`n)0 A n: ]1 u' W& n
StringSplit, word_array, full_path, `n
- D4 H, ~; B0 s8 Q/ u; Z# j# J ; Take the first element from the array; C5 v6 G; _2 T$ Y! P7 j. G' i
full_path = %word_array1%
( Q# u: X+ f2 d q+ J" M9 i E* L ; strip to bare address9 f& d; b( M" v* _
full_path := RegExReplace(full_path, “地址: “, “”)4 C% T2 H. Y, R) B- O+ e }
; Just in case – remove all carriage returns (`r)
0 ]) y4 B, N2 u6 f StringReplace, full_path, full_path, `r, , all
, S- C: o- D% x% q) p7 g0 G IfInString full_path, \. B; F1 H: ^; V9 F' m
{ V1 ?" i2 H' P
Run, cmd /K cd /D “%full_path%”. l5 H. ~. z# c
}
: L. K2 ]+ A, K* e: J else+ M0 h4 t5 U" @/ C, I* I
{' O- u* m9 s+ \! S' `. u, T3 O
Run, cmd /K cd /D “C:\ ”
$ B4 H/ h& A' m- X5 v }
; B$ H: l( X) Y" A- K( N }# L; W' l& T" V' o/ r1 c
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 `( t, {/ U7 X8 n( g 这段小代码肯能有两个你需要修改的地方
$ C( D8 L! x% ^. H1 d. Z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 v$ ~0 Y0 V8 \3 P0 q9 r6 w9 O- a
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 }0 j6 n9 |7 ~" B
|