此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& ?; w& \( o. V& j- o 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
# ~, ?! ]' D' [2 }4 W' o 方式一:* u( q3 v) h5 ]; p P
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# ]8 }. H9 V& a: ~3 L 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
& {& T( A! y$ W6 V, }0 |# S HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。 z3 ]: g2 |6 A3 \0 c0 m6 l/ w
方式二:, Y% N6 x( f: r7 k+ u+ j V
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 h9 k o/ g- R2 T! {) X
SetTitleMatchMode RegEx/ R2 | }- n* y- X/ k
return) k' X) D9 E4 Y4 `) G9 |5 W0 K
; Stuff to do when Windows Explorer is open+ M7 d4 y% _# D, j
;, F7 m$ l \/ S) m: V
#IfWinActive ahk_class ExploreWClass|CabinetWClass
4 J: w9 w0 j* A4 `/ X. L ; open ‘cmd’ in the current directory
3 J6 X4 g4 [/ M# p/ \ ;
, S) s. |4 d P& x$ p( s0 z #c::
8 H* `' E$ ]/ d OpenCmdInCurrent()
, y4 H- E9 v6 Z S4 | return
) n' A$ K, X1 s5 f #IfWinActive
. @# K1 t7 G. I' P( g ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 C& M3 {5 \* f8 q ; Note: expecting to be run when the active window is Explorer.
4 q; _, }- [6 s$ l ;+ t% n4 C0 O- B; F1 K5 h
OpenCmdInCurrent()- I( k, G, K2 R4 e4 L
{
, |3 f8 a1 f' o$ l1 U ; This is required to get the full path of the file from the address bar* Q0 |2 N1 r" v0 @: N" ^" U) }; W' e! f
WinGetText, full_path, A% g& d5 @" e* w3 j1 s) J
; Split on newline (`n)
9 i# C2 Y3 \0 Q9 f) y9 c StringSplit, word_array, full_path, `n
; A( |- k; H5 t' I( Q ; Take the first element from the array
$ Z# {: a3 J% u+ p5 N Y! W full_path = %word_array1%: D- n, `3 F' x3 D; `1 u! d w
; strip to bare address: U1 B/ s( J- D% b/ \/ b
full_path := RegExReplace(full_path, “地址: “, “”)
- l, H* x3 @: w# q& z9 b ; Just in case – remove all carriage returns (`r)" f& N2 ?6 Y+ ?0 k, p% a6 r2 }
StringReplace, full_path, full_path, `r, , all
5 v7 h n3 q, n, e; M IfInString full_path, \
) b5 Q2 R! B! `% w {
$ w7 R* q4 |$ n- F3 ] Run, cmd /K cd /D “%full_path%”/ u- ?* [! D# e3 |2 ?$ Z
}
# p: i" r& P1 ]. g else
( g* Q# W; X( L2 q. E! } {
1 f( F8 \3 N* p. }* \ Run, cmd /K cd /D “C:\ ”
# \- G5 F* x3 e# z" z }
, e2 O5 i) x* f' g( I/ r }# [: D$ X { U. c' C
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 O0 N5 c2 Y. ^- r) m
这段小代码肯能有两个你需要修改的地方
, n" r# A/ J4 r 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键2 _ k4 c7 y8 h$ G$ u
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. U* G1 m* H$ L- q3 k6 ^7 l |