电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ V( F8 i3 c8 T/ [  F( Y5 P, ]* ?  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, [5 Z2 P5 B6 @/ o0 f1 X+ S6 x* \
  方式一:" t, r7 _; I% D- o* D! w. v6 \; b
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 e3 k0 @5 k" E! [9 A; Z4 N, L  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! K* Y! b5 a& L3 _4 d' F4 s$ G! t
  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 ]0 ^+ w# i) M2 P- u/ ?, Y  方式二:
, i6 ]7 L. e3 D8 j  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:% m& U$ h# \( j& }7 X
  SetTitleMatchMode RegEx
9 G+ N: [! c: ^1 ~1 |2 X0 D2 ~# p  return$ `0 \6 g* M9 i) G4 X7 [+ w
  ; Stuff to do when Windows Explorer is open& Y* t1 Q# V8 s
  ;
2 Y" c/ y" @: o$ N  #IfWinActive ahk_class ExploreWClass|CabinetWClass
# y' ~* X# T; d- p: H" r2 u  ; open ‘cmd’ in the current directory
. Z' z& M( t. Q" i0 Y3 G; o1 t  ;( Z* o: U, r( G
  #c::
9 Q8 I) ^  o, [: m  OpenCmdInCurrent()
2 C) C8 L* E7 @4 L) ?: l- l  return
. u# c6 N2 k/ R& c  #IfWinActive  T. ^$ Z" f. R5 c9 K* K
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.3 P: u# F5 T8 h& ]
  ; Note: expecting to be run when the active window is Explorer.% O1 A0 M+ K9 G, t
  ;! P( O  J2 A/ P$ @' t9 b
  OpenCmdInCurrent()3 X+ Z- ]1 c0 Q8 i+ J
  {9 F; y6 B( s0 g- y, d4 }+ G
  ; This is required to get the full path of the file from the address bar
9 o6 _# r0 U% c5 i- G7 R; T3 E% R5 e+ z  WinGetText, full_path, A
; Q! n# T! f$ j" ]  ; Split on newline (`n)
5 c9 q' G' D$ w. \7 S3 T8 H  StringSplit, word_array, full_path, `n
( c3 z/ Z/ V' T  ; Take the first element from the array  i/ \: Z4 c/ Z
  full_path = %word_array1%
3 L& `. C' S( K9 p# N& I  ; strip to bare address+ s8 L' z1 d1 L# m3 b, F9 h8 r
  full_path := RegExReplace(full_path, “地址: “, “”)( V3 @6 T, A/ m, Q5 x2 `
  ; Just in case – remove all carriage returns (`r)
* v/ X- C, `5 [  StringReplace, full_path, full_path, `r, , all
) W  t/ S" W2 x+ K  IfInString full_path, \2 @6 G& \# L( R+ q
  {
) n& t/ f2 j6 m8 i# ]/ Q3 o/ ~  Run, cmd /K cd /D “%full_path%”, \' h  o$ H2 ?0 o( P
  }% @6 L  c( m$ E- M) B* ]' ]
  else
. A, r1 e3 ]. t  {' {3 ?/ ]5 q3 s- J) \
  Run, cmd /K cd /D “C:\ ”) y: f8 {( P9 w
  }
3 C4 t! I! x, {/ V1 _  }5 n3 u# G4 J. V- F, q- J
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 b$ b- s* w* d2 S' ]
  这段小代码肯能有两个你需要修改的地方& W6 V9 Y3 A  `5 N) H' B
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
/ X" r- f4 e. M$ M( ?  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ e# a1 [+ A* G! T" L' I6 `+ p8 `4 |2 g1 O
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-12-9 04:35 , Processed in 0.054446 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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