此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. c V9 z3 B" B& J" T' {! U
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! ^/ x X. N' z; _
方式一:7 I/ W5 _0 B& U% q, s+ P
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
, G- A6 X# o( T 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
# }# q. e6 b0 A- ]& ~ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
7 L' k; u# ~! W1 x9 T 方式二:
2 ^8 }: r" a& _# n7 k 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: Z1 l3 q5 Z8 U/ E2 K& A
SetTitleMatchMode RegEx
! r# f" s: w, z0 u' m& z return- O( R& @0 G# E# H% x
; Stuff to do when Windows Explorer is open+ B* K6 C9 ?4 O
;/ K; Y. }1 u1 K/ G& w7 S5 A
#IfWinActive ahk_class ExploreWClass|CabinetWClass# c8 E3 N$ r5 D4 ?( S% s
; open ‘cmd’ in the current directory+ o) ^0 j! d' E- G
;5 |/ \: O% G* }
#c::& X, Z9 o0 o, u
OpenCmdInCurrent(). e3 `" V# P7 Y
return' H, f6 n2 |: v0 S* g$ t, t
#IfWinActive
- }' N1 S5 H) m( d. C& [# r' ^ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer." i9 D, D) j( s" M/ G8 J: Q
; Note: expecting to be run when the active window is Explorer.
$ U2 I- M: C! J# H ;
8 x7 b7 \6 T4 f OpenCmdInCurrent()* }% c9 y6 o1 [, _0 Y
{
, M. D8 _8 ^* a ; This is required to get the full path of the file from the address bar
! _0 j X. j, u( v8 w WinGetText, full_path, A" g0 Q& L C" s/ S4 T
; Split on newline (`n)
. C; V2 X5 n; b2 y$ b1 k# r StringSplit, word_array, full_path, `n4 P# [0 u/ c0 b5 T
; Take the first element from the array- C6 N; c5 U. [" Q4 ~. o
full_path = %word_array1%& m) P# @1 \2 N% {9 b/ ?0 w
; strip to bare address8 {0 c& }4 R2 H0 w1 \) w8 q% n5 r
full_path := RegExReplace(full_path, “地址: “, “”)
1 ]0 Y) G/ M% d; g. w ; Just in case – remove all carriage returns (`r)" N" h# G' B7 Q6 G
StringReplace, full_path, full_path, `r, , all4 k J' H& i: D: ^) O, h4 i) c
IfInString full_path, \# i3 g& f7 V" [8 t* o
{. q/ f' ~, r0 Q1 I2 Z; |8 ]- a
Run, cmd /K cd /D “%full_path%”0 j( j. @! G$ p! s
}9 F7 R/ [" O) N/ D5 b# l
else! i2 _, A- q$ P! e, x! W: c2 y4 t
{/ c: k5 N" O* ]# w+ Q
Run, cmd /K cd /D “C:\ ”1 |9 g" B- n) ^* I
}7 Z0 Q( }6 L( ^; K
}
3 U9 Y0 _) ~2 L 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
+ d1 K$ X, Z# k) M8 ` 这段小代码肯能有两个你需要修改的地方
- M, M& M- Z0 P9 ~2 _: {3 B 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& U0 m( ~9 I1 T2 ~3 s) }; a: a 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
' C9 d4 P. s# G) K9 A/ p |