电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) Z: r: u8 V" i# H; I% a
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ H8 S: x8 [3 z8 s* m
  方式一:
$ J* {* o! G* X* k% \: U  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) K& f: i. g8 V2 D4 w  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 e% j/ Q6 S- A0 G1 Z/ @
  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* V) N* }* x; b) d( o& s$ C& u  方式二:
5 d- N9 N6 f3 h/ [7 j1 o- L2 E2 R  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
  X2 P2 B+ Y( \  SetTitleMatchMode RegEx
. q7 e' B! F! U- s3 G* y1 _7 J% A  return5 S: A: u, g( ?7 C  W) X
  ; Stuff to do when Windows Explorer is open
  H4 v3 m) k# e# [% |  ;0 _  K! V6 C; j0 f9 G( Q# J: E
  #IfWinActive ahk_class ExploreWClass|CabinetWClass
) Z& j" \0 D! M8 t" Z, Y( J  ; open ‘cmd’ in the current directory
4 n( O# D/ w% J- m/ s! U2 ^" k  ;
! P! m/ L6 l6 {& [% C5 F' `0 r4 F  #c::- `. f# i& h. H4 E, S# ^5 C7 [
  OpenCmdInCurrent()/ m) V  m% g) N7 z8 a. P4 n* o3 F+ ^
  return) ?2 P* X# t+ _) M. J0 ~
  #IfWinActive% E' J  k7 Y- ~/ j$ ^
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
# H% Z( R9 m, T' k3 f  ; Note: expecting to be run when the active window is Explorer.
- q) B; v) L) `% I/ O  ;
8 r) V! u3 T& v* d4 k+ J  OpenCmdInCurrent()# s6 n! P2 r' a' J- z+ E
  {
! r: [7 O$ b& H  p0 G# K  ; This is required to get the full path of the file from the address bar
! m0 r4 G3 v! B: f$ F) m$ Y3 L  WinGetText, full_path, A: G) E; a& _3 W% y3 `! [
  ; Split on newline (`n)4 d4 e5 P3 Z1 k& e- H, r2 s
  StringSplit, word_array, full_path, `n
. `# u0 s4 s2 O- R2 z- C  M  ; Take the first element from the array8 @# o3 O/ c3 c+ G
  full_path = %word_array1%& Z. j" o0 v8 ?9 z; _; |
  ; strip to bare address1 R/ |; i1 v9 U3 E
  full_path := RegExReplace(full_path, “地址: “, “”)
0 _* j& `. e% t0 i. e  ; Just in case – remove all carriage returns (`r)
3 ?, J3 }9 x& I% V# K  StringReplace, full_path, full_path, `r, , all
, j( C* g# Z3 M) `6 r) l* |6 h# [  IfInString full_path, \
! R8 z! J) k4 y5 G  {
- H) {& ~; k# @  Run, cmd /K cd /D “%full_path%”
0 `- u2 q# U: o0 q$ Y0 p; s6 l  }1 u2 A* f0 {/ n0 _+ G: v) d& ^
  else
* V4 a0 |# `' j& j  {
  ], m" t7 A& {2 _  Run, cmd /K cd /D “C:\ ”
! `, F# Z8 Z, P  }
* E+ n( O7 S7 B* e  }
, b1 k( R9 b% Z+ B5 G1 z! o0 _  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: i1 G: V3 P9 |9 H3 s( w$ _
  这段小代码肯能有两个你需要修改的地方
' y! J+ S$ G, w1 r9 Z  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 k% L6 D4 u( N, r7 b
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “6 N# q: P* w1 j- e5 r; I5 `0 o* W
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-4-21 12:14 , Processed in 0.056148 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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