此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 B$ U7 ^9 f9 s8 v
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 q! O. \: Y! R6 j+ x
方式一:
% j1 R( w, e: F8 i7 s- H: O 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 [) \: S: Q* |: ~" n" {4 x 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# `! \6 j; Z) S) P) W2 \- H
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! t$ c/ {& Z% \2 e
方式二:* @7 R! ` Y& M- D( @- a! E
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 n h9 }9 S) A7 n# ~" z
SetTitleMatchMode RegEx
# `3 w" w2 h/ ?2 M3 d$ y6 Y! v8 _ return; I, s1 d {3 @! f0 C, O
; Stuff to do when Windows Explorer is open
! V* H3 o, O- O% w- S$ V" z) c ;
0 g" \ s# {: J; n1 | #IfWinActive ahk_class ExploreWClass|CabinetWClass
) Q1 V1 Q, P6 E* P: {4 S ; open ‘cmd’ in the current directory7 ^1 j3 s; V& o! ?! L9 ^8 R
;$ [# Q* a( z3 X5 R6 h4 |) f. V
#c::, }* C6 e c' c
OpenCmdInCurrent()
4 ?) B+ y' e/ X) U# @ return2 W2 E! d" V9 F; `0 ~
#IfWinActive( n; d" I& m6 P- U: T5 o% ~- h) l
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( w5 ~. f B( P5 C7 }$ M* X
; Note: expecting to be run when the active window is Explorer.
3 E1 ?! v _4 n( e* j2 D- f+ F! k ;
" F u' B' g }. D5 m- K OpenCmdInCurrent()9 i# L2 q8 r2 @5 a" ^3 H
{
x' r9 X0 S0 _$ P+ |8 E ; This is required to get the full path of the file from the address bar
7 j$ _" W6 r- [" |. a/ I WinGetText, full_path, A3 Y3 p0 u* a4 @7 k3 h; w9 p) j
; Split on newline (`n)
0 N1 |; v( y8 t# g# K; u StringSplit, word_array, full_path, `n0 J2 T+ Y5 s( v! H) o
; Take the first element from the array$ B1 I. i. o: ~8 n( Z/ W
full_path = %word_array1%
, J( y; K; x @5 a& P ; strip to bare address" s4 `4 {3 `" f% w
full_path := RegExReplace(full_path, “地址: “, “”)" ?* G/ S/ s; l
; Just in case – remove all carriage returns (`r). Z7 G$ h8 G+ f/ v& k6 P
StringReplace, full_path, full_path, `r, , all# @9 r Y& I; T" y. e/ }9 a. G
IfInString full_path, \
. k( u: X* M, d {
+ W+ @* e0 u/ J" I2 C6 h Run, cmd /K cd /D “%full_path%”
3 i- D" S* F' U) J3 L3 N1 Q7 z }
) D. o% d; g- ~5 V2 d2 x else
* |, i1 m& z+ D7 I* j& G {
* z# ?- I& t. d9 _ Run, cmd /K cd /D “C:\ ”
1 K0 a2 t$ p0 Q/ x7 m2 f' j }
" U0 M! S7 F5 H! C( y H }- V% A- P z1 p- |( Y( P6 x7 V
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! L2 X7 T. c# n' p& d 这段小代码肯能有两个你需要修改的地方
- f: s0 g4 L1 K: C9 H2 E 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; n$ f% ~4 a# L' C/ t 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ B9 u7 _9 D) f) w% Y |