电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 v1 g+ e( u$ N" S
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 ~7 C, J0 }1 N6 I
  方式一:
/ b' u+ M2 ~% W# U  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,' ^$ U" W! `5 j& y) K2 L4 |
  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
$ t, q* Q$ H3 y2 I  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' ~3 [  Q7 ^/ e- K, P% }. }5 P  方式二:
2 M- \2 M  ^/ m0 u5 `# ?  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( ~" f7 [- ^' _+ X0 c5 [, _6 |  SetTitleMatchMode RegEx" a5 ~& |. x# l" E. x$ r( d1 u4 c
  return
' L1 C* s5 {3 a  ; Stuff to do when Windows Explorer is open
+ L& K( K) C, q# \8 e+ p5 O  ;" m; f0 ]4 P0 c0 X
  #IfWinActive ahk_class ExploreWClass|CabinetWClass7 ^& ~# g3 t0 C( E( q/ f# b' C0 P
  ; open ‘cmd’ in the current directory
$ @8 a! d' T* G& Q. p  ;
; R( K( Z% b/ k7 x1 ], W* q; K  #c::7 u7 c9 r  t5 o
  OpenCmdInCurrent()
3 x# }. i' L# B& R* }8 Z/ E  return4 D4 f: Q1 J9 U$ P2 f  x
  #IfWinActive
# J3 t* q/ W, W  v+ F  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ j: g5 F! I7 g) w- J, a6 Q
  ; Note: expecting to be run when the active window is Explorer.
4 {: {; F) d* D0 k0 p* |  ;- s7 t+ ?. ~; y% a" U7 O% P' J
  OpenCmdInCurrent()
! u# l# @# P  R6 k& b  {$ @, }1 h: n; b! a. y
  ; This is required to get the full path of the file from the address bar
2 p2 K& k3 y: l: O  WinGetText, full_path, A' ?) B6 L# @3 a
  ; Split on newline (`n)
- l8 V7 |8 f1 z) M1 S  StringSplit, word_array, full_path, `n
" [# w7 f' `: m$ y  ; Take the first element from the array6 @0 i; r0 h) G" U# Z
  full_path = %word_array1%- I" _& r1 }: B
  ; strip to bare address3 \1 S3 L8 F# I7 Y: f2 D- }
  full_path := RegExReplace(full_path, “地址: “, “”)
0 H* m7 x$ ]5 R) m0 m* a7 X  ; Just in case – remove all carriage returns (`r)( t& `. @9 |8 J: f) p! `; z
  StringReplace, full_path, full_path, `r, , all' ^7 A2 N: s) e4 e; W
  IfInString full_path, \& T- ^6 w7 k( A3 q" s- y) n2 ~& ^1 X
  {7 _, ?, v5 u, f
  Run, cmd /K cd /D “%full_path%”
$ n0 Z/ ^; u; m- v  }4 z" E5 W% d% V9 c% Y/ P5 C
  else$ n) O  |' }/ Y# m) P- r
  {
) s& s1 t/ ]) G7 P2 f1 C  Run, cmd /K cd /D “C:\ ”5 T) M) Q5 P) }( X' }" V' x$ C- p
  }
% ~; f- T" ~/ ^" O  }
! Y( B# t# K2 u; ^  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% e$ O3 u9 n2 u1 G' b
  这段小代码肯能有两个你需要修改的地方* \0 T: m$ {1 \3 o9 W
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. Y5 T  S0 k1 E  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) y! J/ J  [8 Y# W0 \
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-10-12 20:04 , Processed in 0.146092 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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