此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% @! N& V- P) Q v. W+ ~8 b 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 k. B% k7 g4 r; m( d* s$ T 方式一:1 V! |0 D+ `3 ^' O6 q7 V
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( t: b* h1 U; L; c; I! @- ` 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ d4 Y/ K% _- Y) O8 t0 t/ Q
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 w) \ a% B# N: h' m' l C% A- |
方式二:5 o2 h, ]& H/ y' w. S$ j7 s
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. }; s9 @# U" d0 b
SetTitleMatchMode RegEx
0 Z8 c" l; r$ P4 T. X return
O% W8 z3 {% Y) @& c0 K ; Stuff to do when Windows Explorer is open
7 E" `2 a( a( e2 H9 U ;% P7 s+ x- D% d7 v: V; h
#IfWinActive ahk_class ExploreWClass|CabinetWClass- v4 b9 Z7 B/ @$ q" H: S% j9 \4 k
; open ‘cmd’ in the current directory4 t! [% J* M6 v; a: j" k
;* e- N* O p/ s- M9 g2 D
#c::" T! M K# h1 q$ f2 D$ s
OpenCmdInCurrent()- l- Q/ ?! O, n- V% y( ^
return
( {" K5 b% R5 w- J% z( _ #IfWinActive
6 v5 N( c( J3 @. h2 W ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.& T% l3 L1 J2 U7 L7 T, D
; Note: expecting to be run when the active window is Explorer.
, F% f) g: A" ? ;; x+ C v: G: v) `5 K" p$ t3 s
OpenCmdInCurrent()
0 f+ Q0 x) t, r* K/ U$ p! ~! d {0 J" s) I% U0 ~; p" G( e$ ?
; This is required to get the full path of the file from the address bar
: t$ k& Y! X& ]; z, Z' F/ v L0 c WinGetText, full_path, A
! z, j6 y9 i5 ^+ K" e ; Split on newline (`n)& F/ u# ]9 t/ H% }- r
StringSplit, word_array, full_path, `n
& Z& O; J" @ b7 ^ K ; Take the first element from the array
$ K! r" I, R6 ^# _7 O7 W full_path = %word_array1%
" j8 J, i) F; [5 _2 { ; strip to bare address; H) t, v, y' q0 E3 d/ Y# c8 I4 V6 I
full_path := RegExReplace(full_path, “地址: “, “”)( i) c' X" K0 N* j
; Just in case – remove all carriage returns (`r)5 O( |, ]. n( ]5 V# E0 S8 Y
StringReplace, full_path, full_path, `r, , all" A7 U- h; H# d" z9 r, s, a' p
IfInString full_path, \- m& f( [' d* A0 U# Y/ R$ @
{
/ M4 F0 ?0 [* Q9 X, j; l" E6 h Run, cmd /K cd /D “%full_path%”8 x: H' `$ F: ?( f; ^
}
! b- O1 D, C l3 c) b) \ else: j( o/ i3 X6 m
{
, o q5 j) B9 E' q% @& H Run, cmd /K cd /D “C:\ ”- j# R% N. D6 A9 }' L6 e! c7 O
}
* T# T$ o% N7 \3 h- t1 W }
- u) i: x. T/ e5 k 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& v0 y4 ^# j, x
这段小代码肯能有两个你需要修改的地方* L3 X9 V: a* @0 c& D7 v; u
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键. j( v- w/ [. ^$ V( l
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “) c6 s2 c6 _+ M) [: n; \
|