此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' n) f) o4 N+ I+ k 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: s( u8 @' c# {; i' p9 a& j2 N' y# t
方式一:
2 ?" p/ y; N0 K( V( u7 z3 r 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 `+ A, l+ @, s4 y8 J2 Y1 a
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
0 J0 k7 u7 ?* R6 W HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 \: B$ z/ |( ^" V% h
方式二:/ f- J3 n. i# R# g; ~+ p
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 j4 v r* i% D* }+ A
SetTitleMatchMode RegEx
; w/ D) L: r6 h1 ?& @7 M return/ y3 L: x0 X! ~4 H4 q3 C6 f
; Stuff to do when Windows Explorer is open
9 u/ ^! {2 m* e; ] ;
" |. M. G5 W" W4 A #IfWinActive ahk_class ExploreWClass|CabinetWClass
4 N" v, l3 T1 \* z6 d. l8 c! Q0 y ; open ‘cmd’ in the current directory
# }/ a s P0 `: ?, |$ \ ;
; F3 K9 a. {) [/ F- M5 v, X) y #c::
' Q4 n, x7 H) D; ^ OpenCmdInCurrent()
# ]9 u+ Z Z( C" Q return* w% L f8 _7 p K; w; B5 B W
#IfWinActive
, M$ [* |# h8 W/ z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
J; \5 ~4 y% ?) N& \ ; Note: expecting to be run when the active window is Explorer.
; |( S; z6 K' |, K) m ;
2 m/ o# P9 X& q4 K4 V* n/ s OpenCmdInCurrent()
# ^% L( S1 H0 X8 _3 j {
# @8 d( V7 D- U$ G5 [6 y) Y ; This is required to get the full path of the file from the address bar
; ~' _ ^) l8 i) J" E. _9 w WinGetText, full_path, A
+ r. @) F5 z p* i! K# P. e ; Split on newline (`n)
2 f1 u6 q# O+ p0 Q' M StringSplit, word_array, full_path, `n
# U, C' U+ z$ R* R/ x i3 e ; Take the first element from the array/ _) J) n; z: E
full_path = %word_array1%2 i8 q, t Q, W# r' w! i
; strip to bare address
+ V- m; E2 T( W: r6 _# z7 F full_path := RegExReplace(full_path, “地址: “, “”)
8 w! k% ]/ m9 F% q/ ^7 c' B% g ; Just in case – remove all carriage returns (`r)8 C2 G' {# e* a G9 t
StringReplace, full_path, full_path, `r, , all+ g V$ A4 n( t9 a% d+ ~' k" i
IfInString full_path, \
( D# E& j( G8 U1 }. |2 n {
+ f% O7 ~5 q4 |' x0 }! G Run, cmd /K cd /D “%full_path%”5 k% h; x3 l2 f9 C: Q/ B
}
8 n& p8 w( s$ v* v; h else5 h* R8 p/ X* w: C
{% Z; U4 X6 G; r: b* l* B
Run, cmd /K cd /D “C:\ ”9 Y/ X# ^8 c0 K7 [4 f5 z
}
' u5 t* Y% \5 @# I4 u7 t7 C }
# Y9 v, S3 N$ R, C 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 Q+ ^3 j; ^6 d# l
这段小代码肯能有两个你需要修改的地方
2 D! r/ w) e. L/ e) k/ U: y3 o% h 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) k% x+ G- }# s7 K* a
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “' _9 s$ @. N. B+ L. D2 l
|