此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* [' C/ [% }& C3 E
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 N# B5 ~2 N5 A5 l# L4 E4 a
方式一:
8 g7 q5 b& E0 y1 W, D: g 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 U6 g* E% ?, Z8 N& P3 w, J6 |. ]
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' V; s* q& [8 n8 I
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ z# t8 |# w: C4 z
方式二:- U) ~# g" g2 A, S/ |9 ~0 z$ Y
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ p% a& @2 y2 W( k, A4 V" p Z3 Z SetTitleMatchMode RegEx9 m& M# X; x1 W r Y% Z, W+ @$ Z' _
return
8 x+ \9 O3 Q- J1 v9 f u ; Stuff to do when Windows Explorer is open
- K \2 [% W; j" T& e+ g4 ]( a) e ;
' o+ n2 V h9 B6 ~2 V3 T/ N #IfWinActive ahk_class ExploreWClass|CabinetWClass P; R7 R* b+ z# }* }
; open ‘cmd’ in the current directory3 x( X' b- J* ]0 T
;" b4 F: b1 _. N3 k e
#c::
/ w! ?0 z$ t ]8 J6 L$ ^ OpenCmdInCurrent()
1 W9 X* D P! i) P+ f) F& H return: t+ H9 q1 P$ w2 P m0 a8 Z
#IfWinActive
+ G4 g2 k' y# o- W6 k" g/ {6 B ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
& a) v( D4 ?2 Y% a ; Note: expecting to be run when the active window is Explorer.* Q# e$ M0 w6 H, g( [+ t$ H
;
4 D" M0 {3 I5 z+ s" q6 ~) Z OpenCmdInCurrent()* N- m# p1 e0 A# ?' j
{; t& `4 r! t5 T! k1 A0 f( x* D
; This is required to get the full path of the file from the address bar$ K9 ?6 ` q$ q3 b I- H
WinGetText, full_path, A
: p2 `: q: E3 d9 i2 Z ; Split on newline (`n)
; I4 ^7 l }1 B& b& e& k% e8 a9 S StringSplit, word_array, full_path, `n6 u& H, `6 y2 N& ]& |/ @
; Take the first element from the array
8 p' G" w/ v9 [6 g5 g; M full_path = %word_array1%
3 a: a7 P* I' b ; strip to bare address5 C! C5 p6 r5 e4 K7 T
full_path := RegExReplace(full_path, “地址: “, “”)! ^/ S K/ h" m
; Just in case – remove all carriage returns (`r)+ o. ^( }: g: ], i% {: i3 C$ ^4 A
StringReplace, full_path, full_path, `r, , all
. Y% e7 [1 r9 t. S IfInString full_path, \0 D& i; \ `2 ]% }4 j( q$ B: n& q
{! J% p( x' B4 U0 N' k. u: _
Run, cmd /K cd /D “%full_path%”
5 u, m1 ?2 k$ ?7 _; B' N }
! j6 A3 i: |! k2 D5 ? else' d/ a2 }# C3 ]9 d) D r8 T; L
{
7 k, ]5 Z z$ S8 u Run, cmd /K cd /D “C:\ ”* S2 a+ w9 o; ]5 L
}% @' V# v8 A, S3 x1 `1 W0 x
}7 Z0 p. R5 {- K$ A, m" l
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ I$ u2 V$ v p! S1 M4 A8 V. V 这段小代码肯能有两个你需要修改的地方 f/ b; m# \4 r6 _) o
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; _5 H3 l. g+ @1 |! h
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 {) A5 r" R6 w |