此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
" a" S8 k' |2 M9 ` 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& v7 N( t3 h7 k/ n! J0 f 方式一:, i1 V6 X) ]8 Z! v( c! m
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
+ W' ^2 M% _4 t2 X% R 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 Y- @" V% ^) N9 U HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! I4 z4 f+ I; u6 H
方式二:
! T6 P* Y& O- g& J0 Z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, |* H* t. K; o! m9 b/ ` SetTitleMatchMode RegEx
6 ]$ i8 m( v, z. K" {: E0 R return
! ]8 T' @# A/ c7 A; w$ _6 F0 Q ; Stuff to do when Windows Explorer is open* t/ }8 i+ H/ G4 h9 O6 e
;9 ?9 p5 j/ B9 u* ~4 ^# V5 o( G8 O
#IfWinActive ahk_class ExploreWClass|CabinetWClass
5 }: {! U( M1 [2 p% ]+ y2 Y ; open ‘cmd’ in the current directory7 r) M4 p, \% G! I
;. ^1 [# N% [# Q% g1 @- B: D" o7 U
#c::4 X+ ~$ g" ?7 Z
OpenCmdInCurrent()( m% |# ^- {) O# }( d' l3 U
return
" d h. }! U9 E$ c$ E$ @& \ #IfWinActive% Y# W5 K H6 m+ }, H
; Opens the command shell ‘cmd’ in the directory browsed in Explorer., g1 x9 n1 N7 _ a8 ~
; Note: expecting to be run when the active window is Explorer.
7 R7 u- Y( l. | ~; A5 O ;. _0 ?( x( v/ h7 M+ \1 N8 ?
OpenCmdInCurrent()
' R" F, q% a; V, C. u) s {8 i) A# g3 K q; [. E' v
; This is required to get the full path of the file from the address bar
* c( ~) C P! Y% a WinGetText, full_path, A
+ r5 `9 j2 m: Z# a+ Z/ U ; Split on newline (`n)+ Q& U9 h+ S6 D2 e$ Y
StringSplit, word_array, full_path, `n) G8 p# I n9 {/ \) Q/ \
; Take the first element from the array. a; ^9 H7 |! `8 ?
full_path = %word_array1%
: E" b$ @/ F( y5 |3 X ; strip to bare address' I. X- e; T- o% q( C, E8 i: e
full_path := RegExReplace(full_path, “地址: “, “”)
: I% r7 C( b7 L6 H. i# K ; Just in case – remove all carriage returns (`r): S$ a5 ]. ^/ m O# D8 C4 B$ a/ W
StringReplace, full_path, full_path, `r, , all
+ S5 |' s8 A9 N( D IfInString full_path, \
. s" ^/ W, D { {& I1 |5 K& K2 S; A) Q
Run, cmd /K cd /D “%full_path%”1 @% m1 p. ~3 f* c0 |; {+ v7 w% U
}
+ u8 Z: i0 f/ I else& G! }$ C8 _. |# J/ x ]% s
{
" t" ]4 k7 R( X" R$ ]6 W4 ~/ ] Run, cmd /K cd /D “C:\ ”
4 w/ [$ i) M0 C& r7 N7 s$ A _ }
3 T5 J2 W2 O9 { }* ~1 n( [; i. P: F# u* |
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 p- V: s4 T0 Q; P6 d+ C 这段小代码肯能有两个你需要修改的地方6 g6 u9 ]0 N( T6 k3 T% p& ?# H
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 L: h7 Q0 p a- |
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “& x4 Q+ g$ \& m7 [+ p
|