电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( M7 A( P- W2 P) X
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 e9 b" Y2 n3 q+ J; O) y% B5 d  方式一:4 Z% t- U* s: T% n  a
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
, D- \& Z6 s- @7 q, ?  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
9 ^) ^6 o' f7 V! `2 ?7 J  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! a( @9 d; w% ~, U5 ~( i0 X7 H7 J
  方式二:
8 i+ ~0 K5 D) n  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:0 c7 q# o! S( I
  SetTitleMatchMode RegEx+ ^3 P9 U/ R& Z  C" m2 t3 d! _- o
  return; a* \2 Q/ q3 M, H3 q
  ; Stuff to do when Windows Explorer is open
9 a9 j4 L1 R3 c8 [) B, n# [  ;6 B( \3 t' d! s( |$ J' r
  #IfWinActive ahk_class ExploreWClass|CabinetWClass
9 r/ g* p( x% S* }6 k3 B2 K  ; open ‘cmd’ in the current directory+ s$ i4 Y8 D8 D6 e* ]2 |; @! G: u7 P
  ;; p' q/ D2 r: u2 B% B
  #c::* @1 t2 L3 u; {9 y* H2 g; G2 B2 q
  OpenCmdInCurrent()# z" r( n! W( b5 o6 o
  return7 n; w1 h: F- v. V2 \  Q! U9 ~
  #IfWinActive9 D9 w+ k% l2 B) o  s
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ V6 t& B! @; z! H3 {
  ; Note: expecting to be run when the active window is Explorer., D5 x3 m2 G. |7 B2 b( [$ F
  ;
* c- U8 i4 @( Z) b  OpenCmdInCurrent()
8 h# T- x6 t- w7 N2 z0 ~* D  {
( ?2 c9 g3 Y  }+ Q% q' l; E  ; This is required to get the full path of the file from the address bar
0 P+ k( o: o! X: W  WinGetText, full_path, A
- }; Y" V7 A. [  ; Split on newline (`n)
! V, O7 `2 I# }6 h( I6 O  StringSplit, word_array, full_path, `n
# d: @  N& q4 N  J/ h  ; Take the first element from the array; R& i8 p& _! W3 d3 B% w! f
  full_path = %word_array1%' Z  C3 J7 y( }* K, h8 U
  ; strip to bare address! A) Y6 r' G2 Y, C7 V/ p/ [0 U& q
  full_path := RegExReplace(full_path, “地址: “, “”)! w  r/ M( r' _# e5 z
  ; Just in case – remove all carriage returns (`r)
/ k$ ^* H& O5 \% `/ S  StringReplace, full_path, full_path, `r, , all
& m) u, J* j! v4 d4 B4 f: a4 x  IfInString full_path, \) C) r' R8 Q- D
  {/ m& d* c% C7 p" I
  Run, cmd /K cd /D “%full_path%”
+ y; K  ]1 V" {7 @: V8 R- Q! U( v& d- j  }2 `/ M' F% `2 f6 {
  else
1 b3 I7 j8 t! p3 F- [/ B  {& b9 r5 O* ?1 y/ h4 \0 U- D
  Run, cmd /K cd /D “C:\ ”
" ]( ]! d+ _; i2 f  @( h+ e  }5 K8 Y0 J* H- p% \8 D% U# W' x
  }4 I5 e$ I# Z% B
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
+ W; C4 ]7 p  J6 h6 t: S( W! X  这段小代码肯能有两个你需要修改的地方
7 B& T" P3 B) s  B7 r' A  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. l( r4 y9 j% y+ t5 Z( Y" n  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 ~6 ^! c5 ^; o( n+ `/ O9 F
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-5-7 09:29 , Processed in 0.052810 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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