电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。5 n0 }* M1 n7 Z- t4 p
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
( y; b* t  V2 ?2 w5 v" h  方式一:$ B: X+ ^# P& w$ X& i4 ~: N" P
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
' K( p0 w/ J8 u! t1 [9 C: E( a/ [  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' M; Q; J. |" L( D- j& u) b  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 {! e8 I" s$ z9 S2 q1 C  W  方式二:
( e0 s) {) }8 c7 [/ M  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 e0 N! x* r3 u* P: S6 v
  SetTitleMatchMode RegEx+ l3 H5 h% J, b" y) X
  return- N! |$ L5 K$ t; K  w% W& C' |7 ~
  ; Stuff to do when Windows Explorer is open
5 n# f' h, Z3 M$ s  ;* B4 c& q0 h- g+ ]# P9 D, P& C' W5 ]
  #IfWinActive ahk_class ExploreWClass|CabinetWClass
- u3 @! l( i( D  b" |4 a4 k  ; open ‘cmd’ in the current directory
* Z/ C1 L; C; ]+ ?  k7 I6 Q: o  ;
+ Y+ U; i" v/ Q8 B) c  #c::5 w( h8 o, @6 T- l
  OpenCmdInCurrent(). x) a8 K1 d4 J$ Y7 v* J
  return
. ^6 E' E/ G8 t$ F  M2 L  #IfWinActive4 g9 z. l; ^1 f: S. B+ D+ g& q
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( M' W9 [0 {: O  ; Note: expecting to be run when the active window is Explorer.; Q/ x; n( O- b: G3 B, t
  ;( {2 Q6 [) [9 H% ~/ }
  OpenCmdInCurrent()& E) _1 y3 G2 z
  {. x' o6 u: n  `3 z. `9 e- @
  ; This is required to get the full path of the file from the address bar$ o; p* C5 `* z8 y$ f
  WinGetText, full_path, A
' S+ |/ J: a/ C5 S& W  ; Split on newline (`n)
4 [- B( ?- L7 F, l7 W7 S  StringSplit, word_array, full_path, `n
6 |. M2 n8 h) Z0 t9 ~" o  ; Take the first element from the array
& f1 C% Q: T2 R9 w. d  full_path = %word_array1%
( b2 L5 R4 y/ z; z7 h  ; strip to bare address
, K7 ~4 ?6 Z3 D# f- P  full_path := RegExReplace(full_path, “地址: “, “”): {0 \$ v5 h% l
  ; Just in case – remove all carriage returns (`r)- v/ {! @/ _# t' w/ U" H% c& q
  StringReplace, full_path, full_path, `r, , all
+ @7 o8 H  Z9 F' n  IfInString full_path, \
3 D$ y: z8 P$ g* ?$ {/ K. t: s' g  {
5 ]# J3 a& F: t0 [2 l+ j& C# a  Run, cmd /K cd /D “%full_path%”
1 _9 ~# {; {( N/ O! [7 P  Y  }5 x/ \+ f$ I! c- @' S
  else; e- I4 U1 e0 h# W# N
  {
3 n' B. ^. l  w3 d) ?  Run, cmd /K cd /D “C:\ ”' j: p' z# `3 V) K! E
  }
8 v5 ]/ b7 P* `0 T: @  }+ |0 X2 s3 |" o0 a; C
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' M. Y6 Z  M/ J+ O1 z$ e
  这段小代码肯能有两个你需要修改的地方
5 A/ U7 [6 M6 ?5 ?0 D  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键8 B3 y' v9 x1 t/ r: f  g5 x
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ K2 d9 }/ G0 T- g$ U9 @
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-12-3 13:52 , Processed in 0.055153 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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