电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。  T1 s- a6 [, m
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: Q/ W5 l; Y" R$ u) e; u$ z
  方式一:5 n$ b; X1 {: Y5 T3 }0 F
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 q9 R' O5 e1 g: L  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 e( O7 q- z3 S  T* a% e2 E6 b  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。7 i! ~9 H" f* ^; T2 L
  方式二:4 K3 D2 R: c. f
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 c4 C' ^- L9 ]% |" F! R$ E
  SetTitleMatchMode RegEx, N) |( s. {7 D/ d# t' r
  return, W% d, l* x1 r: ?9 {) j
  ; Stuff to do when Windows Explorer is open2 S1 J2 u, ~$ ^) m
  ;* k; c/ |* T' R7 t
  #IfWinActive ahk_class ExploreWClass|CabinetWClass" a! U" f7 C- n9 e2 ~( [  r: n
  ; open ‘cmd’ in the current directory0 O1 d8 x) `+ z, I, O0 N( O: a
  ;, |. |% v- `6 ]* M3 i% t0 `
  #c::  P; }+ v) v6 `% f
  OpenCmdInCurrent()
* V2 i7 _" n( v( J8 O$ e% d6 ?  return$ L" A- r7 y3 v1 B$ g  _+ n3 k
  #IfWinActive8 l! i- }$ K, ~3 k0 b( Q' n
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 @( ^- M. B7 M# J* s3 C: E  ; Note: expecting to be run when the active window is Explorer.
) ?% Z# ^7 r6 _5 h1 D6 a; p  ;7 O9 I1 x& Q5 m0 X5 m
  OpenCmdInCurrent()
* a3 Y. I7 K3 D7 h! l, ?  {
9 ~% ]3 Y6 o0 D; i1 w  ; This is required to get the full path of the file from the address bar# t% N- U4 i: [
  WinGetText, full_path, A
# r4 S# e! @# f: u" O  ; Split on newline (`n)
4 D2 v3 C3 ^4 }  StringSplit, word_array, full_path, `n! L1 ]3 k1 L0 T3 `' D. q5 ^9 x
  ; Take the first element from the array
+ I3 e, H. ^3 {  full_path = %word_array1%/ I% x& A4 v8 y' p: p& }' @
  ; strip to bare address) m9 c6 k& x' x
  full_path := RegExReplace(full_path, “地址: “, “”)$ R. t$ Z0 F- k! x( m
  ; Just in case – remove all carriage returns (`r)
8 R! W& b& s. }$ F  StringReplace, full_path, full_path, `r, , all" h4 I6 `% l+ M) o5 a
  IfInString full_path, \
7 Z; F6 l9 H+ w8 O  {! z7 J7 e" S& [! y$ [( a
  Run, cmd /K cd /D “%full_path%”8 e, b1 p& `! v- s/ a0 h
  }
# p5 G- a+ K) M) q: }% {  else2 `' v7 V' b. u, y1 k
  {: s* a0 k  l! z1 t
  Run, cmd /K cd /D “C:\ ”
6 c9 a1 w+ r( b1 M3 d" a- s  }
) t7 d, [3 _) w6 J0 r# [  }
- e" o. [: S- |1 H& |6 Q/ R0 F  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
  ~) w* T1 y# v8 ^5 e. n  Z6 _( J  这段小代码肯能有两个你需要修改的地方3 r! N. O, X2 ~, t7 h
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( ]( s, z$ z! W! Z4 c- h- D
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “* I+ R# B% c4 G
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-3-11 05:10 , Processed in 0.203551 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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