电脑互动吧

 找回密码
 注册
查看: 6845|回复: 0

Windows下更高效的打开你的命令行

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
) l: o7 m+ {# B  t  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
; a9 D8 w! ^6 {. O$ }1 N6 A  方式一:/ O0 V+ d# ]% Y2 C+ {3 o2 u7 g
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 V; \' X- A9 J. Z) P  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 v9 J' `) g) D: W6 b
  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
2 J5 g9 r7 e3 z: Q  方式二:' K# s$ m1 t7 c  C; z
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 F' S( i8 R( A  O) Z' B  SetTitleMatchMode RegEx
' H+ }$ w# O' I( Y  return
7 p: d6 z/ x' K2 _/ s  ; Stuff to do when Windows Explorer is open- e3 T9 U8 `$ i. V  R/ n% N
  ;  g1 @" B7 Q+ @1 D
  #IfWinActive ahk_class ExploreWClass|CabinetWClass
) s5 w* m3 R4 M; x  ; open ‘cmd’ in the current directory
+ J8 c& N' i" R  v  ;
8 N9 S) C/ \/ \1 b6 Y  #c::
4 }1 I5 T6 Q0 }3 G  OpenCmdInCurrent()
/ F; u- P& E) \% h$ @" d  return2 {8 N: ]$ _: ?1 b2 ^/ [& Z
  #IfWinActive; }5 @5 G5 F5 }. q0 u% }1 I6 e3 L4 G
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 |; `1 Z) P: Y
  ; Note: expecting to be run when the active window is Explorer.
/ J7 t/ w+ \; J& }) c- [. @( J  ;) R, K3 K. I6 j3 b. N
  OpenCmdInCurrent()
) R- p1 p5 M+ h) z. |  {
" w. p. d) w3 Z2 ^0 K  ; This is required to get the full path of the file from the address bar/ e# h5 M( H1 ^7 b
  WinGetText, full_path, A5 D: Y" D9 y9 K8 W4 w2 V! P4 m
  ; Split on newline (`n)$ a7 s; N% O" w8 {4 }8 n$ D
  StringSplit, word_array, full_path, `n
6 k2 c: |: v5 A3 s  ; Take the first element from the array
: B0 b: a& |! L/ G  full_path = %word_array1%9 b' K$ `" \. ~* C
  ; strip to bare address
, d3 \  }7 }4 X6 W' |% [# O  full_path := RegExReplace(full_path, “地址: “, “”)
0 ?) ]3 p* \! H  ; Just in case – remove all carriage returns (`r)
. _" H1 B& K1 C6 ~/ ]6 t; z+ K' D  w  StringReplace, full_path, full_path, `r, , all
  W& p8 W& y( G* K: a& }  IfInString full_path, \
3 w! \, b7 i7 u& x5 U+ Y1 w& r3 h  {* h* @9 q3 P4 ^' H
  Run, cmd /K cd /D “%full_path%”8 R4 ~/ Q  J) {8 @
  }- w( I. ~& h3 r& E
  else  _4 ]  h# g, f9 q/ @0 B( [1 d) j
  {) F3 \+ n3 e" o) F; Q) V
  Run, cmd /K cd /D “C:\ ”
3 U* [' }8 X% }/ @% N! s) J! Q  }
+ o4 w1 d) F2 P! S  }: s" u0 f2 y. H( }  ~5 j
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 \: \0 {$ }1 f* c4 O8 w) T
  这段小代码肯能有两个你需要修改的地方; s1 n% q% Q6 h
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 x( r6 a4 n" c. `) Y
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 C! \" N% P& f- G: h) A
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系我们|手机版|小黑屋|Archiver|电脑互动吧 ( 浙ICP备13037409号 )

浙公网安备 33032402001025号

GMT+8, 2026-5-19 15:06 , Processed in 0.067155 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表