此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 `% [2 A) o# O/ l* c 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 ^" N! R( \, J+ q
方式一:
5 d! ~& D ?3 F$ S$ B7 h 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* F2 H( s; O7 m7 V7 b6 g* A, t' R
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! `. j2 I% q" Z* h
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
. [0 B; O: M( s4 S# L6 V 方式二:
! N: h3 ^+ a4 |4 _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( h3 y+ `9 q0 B& e' y
SetTitleMatchMode RegEx0 @: T. [6 d6 E( T8 @# f
return
: M- J6 ?4 Q: e: c% e ; Stuff to do when Windows Explorer is open1 z# I+ f) t4 t0 v- z
;
& l( [6 L) K. q% p #IfWinActive ahk_class ExploreWClass|CabinetWClass
# \0 H3 T6 R: d0 T6 \- Y ; open ‘cmd’ in the current directory @8 E- c& U& F5 U4 N/ P
;3 s: g1 O, P. `% }0 E) K$ l
#c::6 ?: `) d% m! l6 l* S4 T6 F1 Q
OpenCmdInCurrent()
( q, S9 S% g( u! S return# I, G4 q. W8 C3 X. s
#IfWinActive
, t, K' m t k0 ]/ d; V ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 x. N5 U( I9 s h2 L2 A; p ; Note: expecting to be run when the active window is Explorer.
2 L7 R* J: `) L0 a2 {( e3 f ;6 P& I( k! ]" s; @, v4 l
OpenCmdInCurrent()/ D" p1 K1 z/ w8 n; O
{
- @5 Z0 Q* z# u! p7 X: Q# w ; This is required to get the full path of the file from the address bar
! @ Q) ~( W' D- R( e WinGetText, full_path, A
$ ^( `% V: ~2 Y: k& D" T0 T ; Split on newline (`n)# r$ v9 J1 R. O1 h& K5 v
StringSplit, word_array, full_path, `n& \$ ^( e. A# P
; Take the first element from the array1 q. t8 |- R4 o1 {6 }0 Z! j8 I
full_path = %word_array1%4 r% V G) U- I# V1 t4 E
; strip to bare address
; P' B/ @! a+ g9 N4 K# ~ full_path := RegExReplace(full_path, “地址: “, “”)
6 j; l0 S! `, z4 [) O ; Just in case – remove all carriage returns (`r)" p# B, a7 r* y9 o2 L
StringReplace, full_path, full_path, `r, , all
p& p8 p) y; Z/ p IfInString full_path, \
: u+ {8 ^$ w) v- L {& ^ S3 b! H2 N/ s8 k% ~" x
Run, cmd /K cd /D “%full_path%”
+ J# Z; y# U5 V9 {9 d/ g5 V }1 q% D2 F6 v7 b( k: F
else8 G$ y4 I% N! g2 i: g
{
/ f. g' _6 z/ r- ]! v' a Run, cmd /K cd /D “C:\ ”
# e3 L# E a! R" ] s9 ?; W( L }
5 f& _; E4 X z4 R' Z: d& G( s+ ? }2 ~' d7 I0 e0 P3 j% ~. {+ d1 U
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 W5 o# r% ^' Z, X& u
这段小代码肯能有两个你需要修改的地方
. u7 {- v4 c" S8 l$ H L+ d3 f 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ w" v$ o" c0 ~" j; S9 f 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
& t& F1 P- P7 l1 I" ?, S! ]8 Z. n |