此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: a' h4 B2 \7 g, p& S
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* S8 L1 x0 ?0 A) h 方式一:
2 q8 Y4 x* q4 F: K" Z5 Y! O7 E 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 A( Y4 |4 q5 ^ d% Q+ f
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
$ f6 |0 z) l+ H3 M' d HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 ~9 q2 ] j$ g7 `$ F0 b+ I 方式二:# @) |7 F7 f) V
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" O! t' ]0 c7 S SetTitleMatchMode RegEx* u8 ~5 @: }$ \4 m, j. F* ~
return. m$ S5 q/ }. T* q# N3 N
; Stuff to do when Windows Explorer is open1 J* ^; E+ [1 b* v4 K4 {
;; A$ u5 B# @5 ?& U# T0 K C- S. E
#IfWinActive ahk_class ExploreWClass|CabinetWClass
$ J, `( d; m* v) T" { ; open ‘cmd’ in the current directory* X! J. t' Z2 [$ _' C5 \- c
;2 {6 e) n) e$ n% [( m
#c::
1 c$ H1 B; w. i% v9 V, Y OpenCmdInCurrent()
* \# s6 b/ k+ C& F: F' c3 u3 o return1 ^4 a5 n# m! e X( Z
#IfWinActive3 k+ y- B& h( c+ g2 Q/ [, }- @
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
/ F/ W6 |) c% J4 L! `5 \ ? ; Note: expecting to be run when the active window is Explorer.# Y6 Y" x0 ]( Z& D2 T: r: E7 f
;
$ _: B5 f: [9 w+ E' v OpenCmdInCurrent()) `' l$ \$ S* x/ Z' i
{
& _+ r( K1 H1 p e D* r ; This is required to get the full path of the file from the address bar
/ Q: u- a( G. m) y WinGetText, full_path, A
% u/ q! z, F) M$ \ ; Split on newline (`n)
$ w! G! d/ ]) s1 ~5 s% A9 |+ i StringSplit, word_array, full_path, `n1 C2 O; I8 E3 e6 z! r& ?% `" C/ Q$ y
; Take the first element from the array
! S+ ~' E; n+ K8 w& Q full_path = %word_array1%
) x) q1 R$ P4 ~# g ; strip to bare address0 P& a9 v; N1 {
full_path := RegExReplace(full_path, “地址: “, “”), E9 R$ O0 z( Q% ?+ r
; Just in case – remove all carriage returns (`r)/ Q) n5 p( t! O
StringReplace, full_path, full_path, `r, , all
8 r, p: B5 R2 { IfInString full_path, \
. o' d1 } ^$ l2 s8 \7 F; k {* F( b. T" I7 @1 Q8 |! I; _
Run, cmd /K cd /D “%full_path%”3 _' s" ]3 J% d! q! [
}
5 i; C+ b9 i6 o) F2 B- { else- F. H* N8 F1 X' {, b
{
, r- d3 I, n1 b( m Run, cmd /K cd /D “C:\ ”
$ i) l# ^- z' X5 _/ B$ h8 @3 L7 \ }
7 ~; J: j; p6 J* j2 E# s4 `) C }" z7 i* j4 M* w) ^, q
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 Y* W1 D6 q7 W' R( e% e
这段小代码肯能有两个你需要修改的地方# O# [" G9 _- F+ v$ n, P+ J' d t( T
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 k) q6 H4 g5 D: y: o$ v# |; b 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 T8 X5 q8 n. d" g/ v |