此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
( w$ c4 s/ Y1 Q( h 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。3 n6 {) U( l0 [' T
方式一:
% I# e4 v- m; ^' b5 j9 j! g9 J3 D 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ Y# M1 Z" u% i6 [
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
+ E' d1 B" x" X0 ^9 X HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& k* |* C `9 W; A5 ] 方式二:/ |: L0 u, T! D) }4 c
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ A+ T2 x, U/ l( }% U SetTitleMatchMode RegEx
8 _9 h( C' [ ], N5 t9 V return
1 N: q: y/ g9 E6 R4 g& k ; Stuff to do when Windows Explorer is open
/ D: X* I8 y. ?+ C$ s ;
( P0 u! X) [9 T) J% N #IfWinActive ahk_class ExploreWClass|CabinetWClass& ?8 ?, h5 Z" _8 _
; open ‘cmd’ in the current directory
% Q( f3 O* ]: ~5 C# p ;
. Q0 j3 ?0 l" E #c::
' ]6 N) s# g: ?9 ? OpenCmdInCurrent()
% I# L: q3 V- R& K- ]- W return" ], Y- A$ {# k* z
#IfWinActive- X, w* ~3 j1 ?5 M ^
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.; O# k) N& \2 x; C' @4 p" j
; Note: expecting to be run when the active window is Explorer.1 q7 S9 u$ Z( | m9 B f: W
;
. d/ U( E: T8 \! u/ A: i0 \, _ OpenCmdInCurrent()5 n% A: H+ ^6 [2 D
{' J0 n) s4 j# o' l1 m
; This is required to get the full path of the file from the address bar& |, c9 @: ~% k& G* P/ N
WinGetText, full_path, A1 h: b6 q: k4 X* j( H
; Split on newline (`n)8 E1 h w* w$ C9 u+ o
StringSplit, word_array, full_path, `n/ r, M( H" m3 I7 L
; Take the first element from the array. a& b" |- b+ |9 |
full_path = %word_array1%
# o1 U z1 ` K/ d ; strip to bare address
$ E" ^0 S' |8 h+ r' H full_path := RegExReplace(full_path, “地址: “, “”)' h3 g: L7 Z2 g
; Just in case – remove all carriage returns (`r)( o9 ~9 y: |) f' X
StringReplace, full_path, full_path, `r, , all; \3 p( |7 W- z6 y E
IfInString full_path, \' P' V G9 N5 X- i
{$ y% r* X; c9 ?
Run, cmd /K cd /D “%full_path%”
) B2 H! I6 W# t6 W }
6 `4 w2 b1 G/ U1 y( n else
6 r2 U7 A. P$ P4 _" C {3 Y2 M1 Q8 O( \" Y. U6 C5 b
Run, cmd /K cd /D “C:\ ”
* @) W9 K H- X) k6 v+ u# a }! v! ~) C+ T; ^! y/ e
}' R# L; ]! |8 m/ p# z" h
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 f. f F' x! K, y& A' j) a
这段小代码肯能有两个你需要修改的地方
' a' |2 M! E8 R; K" R 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ s; S# ]* a8 @- t* A
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 c7 a2 T' y* N& b+ m |