电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" f( {3 j. ^3 `) c* w5 N
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- v) y% e1 t6 i3 j1 q( j4 M, Z1 L  方式一:1 U# ]% F* f1 ~9 R. k4 H
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 W: k0 r/ Y6 ]1 f; y, @* P- z2 a
  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ \" ^/ }2 z9 E0 J: O9 ]
  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ {; @2 I8 t1 u' n& v  E
  方式二:
  _9 Q' D  O. u3 S- k  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! [6 m0 H9 d' c
  SetTitleMatchMode RegEx
  _6 u2 @& i6 T2 i# t* y  t  return
5 e3 e+ e  C/ d! q( ]  ; Stuff to do when Windows Explorer is open
9 E: ]* U! N8 {! ^8 W5 }5 H  ;
/ Z9 T8 r& X, l2 w7 Q  ]3 R  #IfWinActive ahk_class ExploreWClass|CabinetWClass( _1 {3 z: L5 O, D8 u* \
  ; open ‘cmd’ in the current directory+ g9 T% n- |3 C; W" C
  ;
! m- V7 J6 O! C. M/ x. V  #c::
( h  P( W0 a  {* b) B- L  OpenCmdInCurrent()
* k2 u% l  n1 @  return
/ g8 `1 A* D+ \6 s8 x0 j. o  #IfWinActive
# P. h5 N; C: d- q  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
, x: E5 j; c8 D) k# s  n& A; Q; X  ; Note: expecting to be run when the active window is Explorer.
8 d1 M- l8 F) ]! q/ q& T  ;
3 ~) F: m. C1 \. F; J, m; m  OpenCmdInCurrent()
. K1 ?' i! W% ~, M" C/ W  {
7 d6 k+ w* H+ Y1 T( ]5 d0 ^  ; This is required to get the full path of the file from the address bar4 m9 A2 N( D6 E" a+ V6 Y
  WinGetText, full_path, A  P3 C8 g, B+ L1 u' m$ j. ~# H
  ; Split on newline (`n)2 u% X, `7 ]3 C8 Q& g
  StringSplit, word_array, full_path, `n
- ]! [* K7 `; t; ~, J$ B$ K5 ]% o  ; Take the first element from the array* o  ?7 B  T* v+ @, g) O. M( r6 Q' c5 l
  full_path = %word_array1%7 ^8 U. C+ {" Y; ]  g
  ; strip to bare address  w3 x4 V% |( R+ o3 L0 v
  full_path := RegExReplace(full_path, “地址: “, “”), ~/ E. P$ @0 o0 W  n
  ; Just in case – remove all carriage returns (`r)2 i6 a% @" l) a1 c: c
  StringReplace, full_path, full_path, `r, , all
! ?2 w4 ?+ q" e$ |4 }3 E3 c% y  IfInString full_path, \/ k& }! M' E) A0 L& n' J& B  H5 D9 Q
  {! f% |! Q8 R6 L% W* _, d+ A! @* x7 ]
  Run, cmd /K cd /D “%full_path%”2 Z% b: D" h* W3 _4 d7 ~
  }$ A: b) i4 ?5 q% \; `9 \0 Z+ l
  else
( g4 g! ~7 G7 r" J2 y4 B8 W  {% T! v% ~! l% u! S
  Run, cmd /K cd /D “C:\ ”
2 @- b% u2 V- u7 E. t4 B0 H" ~  }, r! t# e3 N; {* @
  }" z* G5 ]! C) s6 {' G7 q' _
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。, m  n6 F- H9 U
  这段小代码肯能有两个你需要修改的地方  U5 ~3 Z' A# N5 @
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ `0 j- D( Q5 R3 N% R- b+ @( H0 }  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 _4 T  A6 m6 X6 E: n) n
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-5-23 04:21 , Processed in 0.138091 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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