此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
1 I1 V2 U4 e$ H2 T 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 }# S% T! F, F Y 方式一:) k) U4 _: v% F( k
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ ~7 p/ N2 `. ~1 Y( j! o x" m5 V* |
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和. M% F) r6 X4 x- c: U
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 G: I$ P( g# N. k
方式二:
+ c+ S) x+ G! n: W0 N 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
! c5 H3 z% A4 O: T4 a3 j SetTitleMatchMode RegEx
/ i. e3 N1 D2 G8 P/ p3 |: h return: M8 ]7 t8 |' r$ p+ t3 P
; Stuff to do when Windows Explorer is open: F$ T0 l$ \7 L2 |1 N D
;
0 b" g) I! {; p/ W: z/ T+ A# V+ x #IfWinActive ahk_class ExploreWClass|CabinetWClass+ g4 X6 Z3 W/ ?+ g. [
; open ‘cmd’ in the current directory' i% v9 f- V! v! O% p* H E
;$ c* D o) \0 d
#c::
4 x( W9 \8 N2 G* @3 r7 I- q& p OpenCmdInCurrent()# G5 `' c" o% J
return& T( h+ {! E! L/ d* U# s# b4 w
#IfWinActive" T& c" |9 ?/ K( O
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.! Q& _; T" C9 }9 D
; Note: expecting to be run when the active window is Explorer.
" ^0 R- U- L. u9 C' S4 _ ;
; S" D1 n0 q5 m+ \/ N; l4 L OpenCmdInCurrent()
$ e4 u S$ `+ C$ N' n {
5 y2 h, k6 S P9 o ; This is required to get the full path of the file from the address bar7 z4 ~! f) d" i/ y& f. L1 L
WinGetText, full_path, A
% z3 @2 \* V- v2 s ; Split on newline (`n)7 j- |: ~+ B4 {
StringSplit, word_array, full_path, `n
" ]1 \, t$ P, \ K ; Take the first element from the array
" u' n$ E) D s full_path = %word_array1%% I! T# k( k1 d. S$ j) C# S
; strip to bare address
% p7 `, U8 U6 d* Q( i full_path := RegExReplace(full_path, “地址: “, “”)7 ~+ t4 q7 Y5 D" R, P1 k
; Just in case – remove all carriage returns (`r)
) o/ Z" [( u1 C) m' t4 y. e StringReplace, full_path, full_path, `r, , all
% }' b' k- ~/ D1 R9 I& W( K8 h& c; J IfInString full_path, \5 u: h( Y2 l6 h, f J4 Q) @
{% d' H w. F: B' ?8 ]
Run, cmd /K cd /D “%full_path%”3 _. z% b4 X, ~! m+ z# G5 d, y) F8 I
}: {( X8 \; Q# Y8 j; H1 n) i
else: J E% P) i6 C8 E! D. P P( Q# R# f) D
{- ]5 z( O, l9 \2 K- u
Run, cmd /K cd /D “C:\ ”3 U) F3 e0 d% p, {4 E: h i% M
}/ U. s) y1 ] b9 q; Q* L
}) b! K/ O& M3 s# ?; a
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
/ d! T+ x* Y+ y: X/ f7 E/ x# m3 [ 这段小代码肯能有两个你需要修改的地方! `5 @& F* v7 o2 ^
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% o. U6 z9 J0 e2 v
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# T, d& K! D* P2 M4 p- s
|