此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# I. }2 @& ]) z7 T' u5 R2 k
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 T) h4 b+ M% n7 P 方式一:
4 }" P; c, w/ L b" x 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) s3 Y3 f2 m( {3 I3 c$ z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 u* d$ p* n* c' f% P2 i. n8 c
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 y* v2 Z# J6 c! e1 Y/ P2 C 方式二:
% E1 u6 J. T5 z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: a6 m, n1 j8 c
SetTitleMatchMode RegEx E. ~+ `$ b% o+ P3 s
return
* k$ D: e/ ~0 r# F" A ; Stuff to do when Windows Explorer is open5 o# q4 @6 @3 N8 F7 [; @
;2 Z; m# z# r/ q r& C
#IfWinActive ahk_class ExploreWClass|CabinetWClass
; o( |$ E) }7 B9 {3 c' e6 O* E$ M: X( \ ; open ‘cmd’ in the current directory
$ ?$ T2 o- T6 S3 | ;' v$ |$ G& v# u/ o) e) I0 J% N' q
#c::* _8 V" o1 W4 K# A7 m/ J( V
OpenCmdInCurrent()" ~2 N( x" A0 J5 p: s& b* |
return
2 N- T2 h8 M T #IfWinActive# r& {% z* i: d, _
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( u0 p. \$ A5 Y- g ; Note: expecting to be run when the active window is Explorer.
" o: h/ Y. v6 _; B ;
+ @9 @+ M) h: C& U) M/ G OpenCmdInCurrent()6 S4 h% B6 ]* I" u5 N8 k/ c
{% z% F( X! H9 s2 V3 u% a
; This is required to get the full path of the file from the address bar
3 t$ y1 `2 }' r7 F: L# D4 D; u WinGetText, full_path, A
! w N# G; f1 M( j+ m0 f. e ; Split on newline (`n)2 v: E! X- n* ]: Y& J& a K
StringSplit, word_array, full_path, `n" s& g1 e d5 O/ B" e$ f5 D
; Take the first element from the array0 d; d# I8 n& f# [; y- o
full_path = %word_array1%1 {2 Q( R n' P8 W" p
; strip to bare address
: @4 J1 `! a/ @ full_path := RegExReplace(full_path, “地址: “, “”)
( s. {2 P% i) d" W/ { ; Just in case – remove all carriage returns (`r)
* e, S8 ? p: G3 N/ I; S* O p4 Z- [ StringReplace, full_path, full_path, `r, , all1 a. K5 }" A& v. z/ |2 w8 R
IfInString full_path, \
; P) x9 f7 K5 [8 x {
+ b, d( i6 c" d( H' J4 N Run, cmd /K cd /D “%full_path%”- _; h& C9 C! N8 @- F
}
. y& T2 k* ^0 F8 l* Z else
5 U0 f1 d& s' y+ J. a {2 J. n) ~5 a( b2 _
Run, cmd /K cd /D “C:\ ”; D% U1 U' L# X; j1 X) @ P
}) N6 l$ t8 e, J' ?) M& X/ K
}
( H' B' R9 G3 E/ g4 w' L. U 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* a m; [: V: W( d 这段小代码肯能有两个你需要修改的地方
8 [. n# P3 `2 P 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" s, a) f) S: r& y/ ` c# ^ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
- G$ n. u/ R0 J# R |