此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' g9 ? {3 _9 `$ V9 J0 D6 P 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
+ k0 `/ s+ Q+ a; s( ~ U 方式一:
0 ]& W' T* ~- x 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% _' F4 @% L: K, W# v6 _ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ t9 t! X; k* d" m. _$ S3 v" h; O4 t
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" U1 \) i: l) H1 h4 \$ t: ]' f
方式二:+ I2 M$ N4 \5 x/ ^: r }! J4 H7 I
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( n/ U5 f) S9 {
SetTitleMatchMode RegEx
0 X4 G% G! G# }$ B return
) J' S$ L+ s8 B ; Stuff to do when Windows Explorer is open
+ R- r' g `. r4 G$ e K: ?, } ;- @3 t7 s5 c2 {! s* @7 ~' _
#IfWinActive ahk_class ExploreWClass|CabinetWClass
! p/ c& @' x/ ]% S' i ; open ‘cmd’ in the current directory- a3 ^8 v/ z0 m# A# t; Y' x( m* g
;% I4 b2 }% W" w6 J3 D/ ?5 t
#c::
$ c% J' q6 m3 a! C OpenCmdInCurrent()2 k" {0 @( \. k7 l3 }
return3 {" y d2 ?/ f
#IfWinActive6 \! @) A8 A" o9 c; K! P( l* [5 ^
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 i9 y/ _. s: p: D f Y ; Note: expecting to be run when the active window is Explorer.) K$ R' n& `; m
;
& E; J* C' U" x5 h OpenCmdInCurrent()
" L8 L& @8 q1 T( O* P2 A {" Q* A1 }7 P6 E2 v4 n. C8 |
; This is required to get the full path of the file from the address bar8 x. R3 Q$ c0 S8 ^
WinGetText, full_path, A
7 B, K$ }7 W$ j ; Split on newline (`n)$ _5 X( e' a; G4 C4 A/ u2 P4 I
StringSplit, word_array, full_path, `n
2 {% P3 N7 z" R) y c. L' S ; Take the first element from the array
$ _2 W8 x/ U! t full_path = %word_array1%
0 q* ?- ^& W- O$ t5 {' N- q ; strip to bare address
1 S' L7 F# c; M( z, o4 @ full_path := RegExReplace(full_path, “地址: “, “”)
. c0 V3 z7 t E( f. N ; Just in case – remove all carriage returns (`r). o0 R$ o- A0 a& \9 K* l' M
StringReplace, full_path, full_path, `r, , all/ Y( p9 n% ^: f* @; ~& Y9 U4 ~3 J
IfInString full_path, \
) ]( K$ l5 e% b) q( R! E2 O: w {
n" ~" l. a- q f9 R( \ Run, cmd /K cd /D “%full_path%”4 {( A2 \& P% G! o5 M
}( q6 G4 t. Q( P1 _9 `
else
$ M/ g# B! a9 Q8 [6 z) v {
& \. L) y! X4 b: G7 R3 M8 d o Run, cmd /K cd /D “C:\ ”) W" C1 a; u; ], O
}
6 w4 {8 P% w" E4 Q }
3 V: D6 I' E' S& B 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 {8 b& x# I$ R" d$ L+ \0 B
这段小代码肯能有两个你需要修改的地方
+ w$ @# R* J3 h/ c; y 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
@+ p) s- C3 @7 ` 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “7 Z( N7 ?0 E0 ^/ j9 o7 x% I
|