电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
" P0 p  ]4 b6 A9 ~* V8 p  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 l1 l3 ?# y+ T' @3 v
  方式一:
. q) g- h* I) A4 d; h3 T" I  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,0 t4 ~4 i8 r, _0 J9 t7 T
  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 B9 G5 y) S: V( h- C7 T
  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
  y; {/ y. ~# R1 @+ f5 a6 d  方式二:7 [+ [4 t: U1 Z4 `5 r) C
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 R, o7 `3 T  k6 U4 E5 c: c- L8 h  SetTitleMatchMode RegEx; a3 \9 j4 C6 n  X: k
  return
$ L! H$ V* Y+ y% Z3 K  ; Stuff to do when Windows Explorer is open
) H6 y" Y4 ]3 ?. y  B, L  ;$ C6 B- s5 i1 d: S& f
  #IfWinActive ahk_class ExploreWClass|CabinetWClass' N/ x+ i) a+ z8 T3 t; A* p1 f
  ; open ‘cmd’ in the current directory
& l& x0 q9 M. s  ;3 J8 i( [+ j2 D& _3 v
  #c::3 B: v! F, l9 J9 W; `2 S% Y( c3 K' _
  OpenCmdInCurrent()3 m/ }8 X$ d: L& R
  return
5 C6 o, A8 G/ ?" |/ B  #IfWinActive
5 Q3 _' C- z+ X8 x- ^  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# P9 X8 U5 n1 z0 Q1 p4 F
  ; Note: expecting to be run when the active window is Explorer.4 r8 t  U" h1 `% {" G
  ;/ j2 V! y% W$ v' O( G8 b
  OpenCmdInCurrent()
, t! ?3 c# n7 c! h. \  {" {2 Q) W1 h' M, @2 T
  ; This is required to get the full path of the file from the address bar
- G+ c( B# t- H8 v7 s- Z' X7 N& h4 X  WinGetText, full_path, A
- M  `+ T; j" _% Z  ; Split on newline (`n)- f3 P# k& J5 Q6 a+ A
  StringSplit, word_array, full_path, `n5 ~0 f6 w$ \% U7 F6 x
  ; Take the first element from the array
( A# i" q7 i" u% Z2 K) N( ^) |  full_path = %word_array1%# b4 C2 t0 _7 z. [/ S+ y0 q
  ; strip to bare address
. P, U" p/ L$ O3 c3 x# h* l+ |  full_path := RegExReplace(full_path, “地址: “, “”)
( m; O. W% u5 p  ; Just in case – remove all carriage returns (`r)4 d5 u$ D3 ^# S
  StringReplace, full_path, full_path, `r, , all
) p1 v) o2 `& [. e3 u* E4 H: K  IfInString full_path, \
8 i( F. e/ W4 W7 f( X9 u& M  {  H1 _9 [5 o% z+ m
  Run, cmd /K cd /D “%full_path%”
, t) \# i# l( w# l  }
0 j! ?& P- y% ~6 D$ p) Z5 |  else
  H, `8 j/ l# B  {+ j0 E- C7 J4 ]! J8 g) R  J
  Run, cmd /K cd /D “C:\ ”5 N( @! }3 ^2 s9 Q8 I5 Z0 Y
  }
3 ~7 u. ~6 y: V& W& |8 R2 g  }
$ m5 m: v/ N6 v" f  y; P  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 R( w  V' O9 y% ]  这段小代码肯能有两个你需要修改的地方
& r/ I0 t& K; N* j% }& w" X4 l  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
  v( l: T# m! n: l  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 K. S) s$ X1 V, h
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-3-1 23:57 , Processed in 0.057893 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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