此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ S6 ~% e8 p: l
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
/ m. Y! W6 E3 h$ M2 C/ R, j# T 方式一:
, m8 g8 d' Q5 a K 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% K) j: n5 @. W
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 ~4 S* P% s; |
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, D- H: V3 `; Y4 C
方式二:
+ ?8 c, A8 ]' ]" L& q% Q9 E 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:) U1 D- J; ?' R9 m; a) I
SetTitleMatchMode RegEx$ A$ r: F6 O7 f% S$ \; ^% T- `" v3 P
return
% x8 J* k1 G3 p& [# R8 [* ]2 x ; Stuff to do when Windows Explorer is open
2 Y' {3 X7 H6 L N' i ;
4 k1 I* w4 N- b) k6 j0 }0 { #IfWinActive ahk_class ExploreWClass|CabinetWClass
* O* g$ p* H8 o/ V' Q1 M3 j, f' N9 P ; open ‘cmd’ in the current directory
/ d7 t! x) S* Q3 ]" O5 ^" M5 \ ;+ m1 E3 v2 p" n& D% n
#c::
- o7 @/ F* ?$ V' c) E+ N OpenCmdInCurrent()
) M2 a- F5 h! C return1 C9 y8 O X5 y* a: u, `
#IfWinActive4 X+ y- O$ ]9 I/ V: f7 Z# _8 ~! i
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( r5 `2 d9 w5 `% e ; Note: expecting to be run when the active window is Explorer.. f' Z- U" S; S% p# h& c
;
7 y' a' M2 ?+ t* W7 J& ]0 J# O: Z1 G OpenCmdInCurrent(); F$ i( w! M3 d4 k4 L( K7 w; `' t
{
( g/ Y/ w8 c# e ; This is required to get the full path of the file from the address bar5 K" F. R: n& I( D' Z3 }# Q
WinGetText, full_path, A
" p/ J+ s" k o% Z& O% V ; Split on newline (`n)
9 T9 r$ D$ Q% K8 u/ {+ ~ StringSplit, word_array, full_path, `n% R4 m: f/ R/ Z4 ?; S- b
; Take the first element from the array
* }1 U3 q: F; Y full_path = %word_array1%9 h7 ^! z7 j" ?- s3 y3 u% A
; strip to bare address
: `% q. R3 D1 d4 ] full_path := RegExReplace(full_path, “地址: “, “”) {4 W1 ]5 I1 h, J. r5 B3 H
; Just in case – remove all carriage returns (`r)2 j& z( ^2 W8 V/ P: ~
StringReplace, full_path, full_path, `r, , all
! ?2 A9 B$ L: c8 X) D2 Z, t IfInString full_path, \
( j* q1 j. `( N. m- I8 } {8 J% Z% Q1 |' O; d
Run, cmd /K cd /D “%full_path%”
! f, n1 `, U) X$ N! J& v }0 G" y& W5 ]' b/ J- A
else
4 @$ ^! j9 I1 p {
; i' J n! h7 @+ r# \: m Run, cmd /K cd /D “C:\ ”* S# Q; h* ?% l) s* ~8 n. z
}
v1 J/ Y9 c+ v. s+ J5 ~5 P3 ~/ x }
- {/ T' y$ ?* W 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
1 v; t2 \% e5 Q8 x# ?3 n' l 这段小代码肯能有两个你需要修改的地方
4 [6 N- }# G5 F$ f, q9 R 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- V4 J, J* d5 ~ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “6 ]5 S" U, C' S6 x$ g0 w5 P7 z% T8 m
|