电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. a% u0 Z% r$ P6 L
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。" L: u. d7 u( O. J
  方式一:
4 x1 p6 [& z% }5 L; t+ x  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) x2 h" t4 @$ J3 q! z  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) `3 b( s! C6 u7 f5 `* I2 G  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ p4 U3 [' b+ V, m& V
  方式二:
5 n: a+ b$ h  A4 J: f$ ^  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, G! k* M9 ], |% W  _* a' t3 `  SetTitleMatchMode RegEx' B8 n: _5 Z: y+ u4 d! r8 ^
  return
3 F8 f8 T9 ]4 z- _0 C; A& z  ; Stuff to do when Windows Explorer is open
$ f" A1 M0 T/ {% {8 Q: x  ;
- M" u+ T) D$ l; `2 a' z" Z9 D  #IfWinActive ahk_class ExploreWClass|CabinetWClass
/ X3 K: Q" d1 M- E  ; open ‘cmd’ in the current directory
4 K$ }3 m: F4 l6 S5 j0 u% Q# @  ;
& k  m+ E/ k' x7 q4 i  #c::
! }3 Y- Z& q4 m8 [  OpenCmdInCurrent()
- C2 y4 ]9 Y$ f0 D$ ?. }  return
  o, j0 b& B3 _$ S9 R  #IfWinActive# |* e# ]  Q9 y4 h
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
! \8 [) d1 P( N1 h$ f  ; Note: expecting to be run when the active window is Explorer.; i( X0 d. L& g% w
  ;0 e* @: K* ]/ F
  OpenCmdInCurrent()9 h0 a) c$ C6 R" U5 V
  {$ R; Z' u# @) O6 U  d
  ; This is required to get the full path of the file from the address bar, l' v/ I0 \: c& ?1 k* H" d& L
  WinGetText, full_path, A2 f; Z$ s8 t* N. ?/ ~7 W+ @
  ; Split on newline (`n)" n1 y( ~3 K' N8 o
  StringSplit, word_array, full_path, `n' s+ {  v+ u3 i; T3 V, v
  ; Take the first element from the array1 q7 t7 }2 P6 y6 C
  full_path = %word_array1%2 u- H* h; }  ]; V! D- S2 @8 B
  ; strip to bare address
2 ~1 Z. A( M* a; J  full_path := RegExReplace(full_path, “地址: “, “”)' U9 |9 H. f: h" I5 [+ N
  ; Just in case – remove all carriage returns (`r)
! u$ w. M( Z8 H  StringReplace, full_path, full_path, `r, , all
. ^% s. |# G8 A% @2 X: Z* g7 Z  IfInString full_path, \
5 Y7 i' p1 v5 t% t  A  {- z) r/ [% E' G3 J  }  w
  Run, cmd /K cd /D “%full_path%”
) `; u- D7 g/ |  }
' V7 i0 b6 x  E0 a- b! `7 Y  else4 _' N* }9 R# W
  {
6 o* ~5 q+ i1 t: @! y) \* r  Run, cmd /K cd /D “C:\ ”" d9 e0 G: m- L& E) r/ o
  }/ j5 H  U, D. ]) z
  }
6 _1 b+ J6 A, ]2 u- q( z0 x  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。$ N- w, m1 v) `( e; {) C; Q
  这段小代码肯能有两个你需要修改的地方: @6 z& y1 w% X. B
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) k* o/ D3 L5 t  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “8 k( d. R$ _9 W( o# X' v! m
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-5-26 01:12 , Processed in 0.148328 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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