电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; @0 r: K0 ^; _. i  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
  h; N% t- g; K8 g3 C3 A  方式一:+ a- [3 F& R  ~
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ a- \& Z" N' t/ H  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ F  a/ m3 p" {" |
  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
8 \4 x4 ]$ w0 k: U! G  x; P$ J1 V4 e  方式二:
+ i1 Q+ f& @7 F: M  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
4 ^8 z$ m! q+ d. b5 |1 {  SetTitleMatchMode RegEx' Y% }' d1 j+ T- @; V
  return; M6 m" t3 y0 f$ _
  ; Stuff to do when Windows Explorer is open
9 e$ u" Q+ C. @2 p! z: K1 f  ;
8 ~! v1 \1 |! i2 q' o% R. s  #IfWinActive ahk_class ExploreWClass|CabinetWClass
  p- Q8 ?* n/ E  ; open ‘cmd’ in the current directory7 J' ?% ~5 h9 r0 \. z, Z/ u
  ;, ~0 S! [- U4 ?0 a0 L
  #c::
* y( c, H) ]! y  OpenCmdInCurrent()1 a$ J- y8 H' G$ m
  return; C) a9 L  D( c. Z' g6 w, B
  #IfWinActive
+ d+ t* N) ^" u7 o! R' N  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* @/ R: N+ `8 V6 H. S/ `  ; Note: expecting to be run when the active window is Explorer.. }: F1 Y" n( c6 K
  ;
3 s/ N% }& v# W" a; |  OpenCmdInCurrent()8 V0 V' K/ ^4 Q: i; s/ \' L' x
  {
, }& Y. E+ ~+ l5 O1 [2 c  ; This is required to get the full path of the file from the address bar
# K8 ]# d, t0 d% \7 D4 x8 _- T  WinGetText, full_path, A
' e. ~! ~8 T6 C8 U! L5 l  ; Split on newline (`n)% @* x1 [# a1 O: H5 D. I
  StringSplit, word_array, full_path, `n4 \( B, ?- G) B7 B6 }8 N- _# L" {
  ; Take the first element from the array
0 {, O( p& m- o) u  full_path = %word_array1%
" o/ Y! v8 k0 f( `  ; strip to bare address
: ?& S& F( i. W7 g" k- H& m  full_path := RegExReplace(full_path, “地址: “, “”)
$ L+ n, d; u2 \! U2 F8 _, t5 g  ; Just in case – remove all carriage returns (`r)  ?9 Y$ s( _: k: O
  StringReplace, full_path, full_path, `r, , all
" X% Z5 s& V, v- g6 O  IfInString full_path, \9 }* V5 C8 [* Z0 ~5 K0 y4 O
  {
& L! C8 y, v4 P- n* P9 W, s  Run, cmd /K cd /D “%full_path%”
. k9 L+ k' |( U: R1 Q  }
1 f3 @9 P, j2 v, o; T4 t/ j  else
7 m$ X" M; e, s  {
$ K- w6 X; w/ }  E: L8 X  Run, cmd /K cd /D “C:\ ”
. f$ u8 C; l/ x' H4 T  }6 c& D* b9 m: f+ e
  }0 `, h! A9 |' I3 [5 Z3 r
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
) B% x7 r$ n" c  这段小代码肯能有两个你需要修改的地方
4 y! [2 O& l, T$ Q0 _. T2 w  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" h- `( Z! G7 }1 L4 M. ?& `# b  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 S1 x5 ^9 H1 c# A# h7 Z
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-5-13 04:08 , Processed in 0.053744 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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