电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 H/ E6 H; @& A2 G, Z  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ f4 h4 ?  E  _1 T
  方式一:! o3 i# H* M' W0 H: C7 e5 }
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ u' Z) a/ H/ ]1 s7 h  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: {5 D) |1 h4 ^: l  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- w0 L: `; x- P$ z% N1 g7 }$ J
  方式二:
: ]6 X9 i. [5 Q$ y/ p8 t, h$ N  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; q' k) W6 w" [& s  SetTitleMatchMode RegEx5 s& \& N5 B7 H6 [' D0 p' j! L
  return* d: q7 u1 C/ d, _: m
  ; Stuff to do when Windows Explorer is open* r' x: ^8 x  B- r9 q
  ;; w: M1 S$ P" U
  #IfWinActive ahk_class ExploreWClass|CabinetWClass- l# p8 w4 H4 y+ m1 t  p# l
  ; open ‘cmd’ in the current directory
) v$ z: {& {/ ]0 g4 `) t  ;" c+ W2 ], q* {. h, y* K0 A2 N
  #c::
3 J: d% K5 J' F6 N4 V2 E( Z  OpenCmdInCurrent()
2 K# k; P( Z# l/ z, m3 g9 N  return, q; T, {: l3 g: _
  #IfWinActive7 T  l! _' E+ }2 n" E# ~
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
/ p6 |( P& Z- @  ; Note: expecting to be run when the active window is Explorer.
: P, M& C8 ~! `/ H( \  ;& C. A4 x/ w- h& P1 Z
  OpenCmdInCurrent()
- q* M5 M" {  H- W  Q9 Y9 F; d! ?  {
& x8 g- y$ C7 ~1 B  ; This is required to get the full path of the file from the address bar& X9 X  U7 q' t" q
  WinGetText, full_path, A( E: B, V& k' W/ _: i
  ; Split on newline (`n)2 K- O7 Y: g6 y1 e7 _! Q! D
  StringSplit, word_array, full_path, `n
' g% ]2 V3 `8 V3 D9 b* c- W  ; Take the first element from the array" K% _7 e+ ]  H$ _9 T
  full_path = %word_array1%
5 D5 t+ q; G9 u) W0 F  ; strip to bare address
4 G' U) c( g/ g! ~  full_path := RegExReplace(full_path, “地址: “, “”)3 t$ a/ x" z1 U
  ; Just in case – remove all carriage returns (`r)
; z1 o. N; Q% a+ X3 R  StringReplace, full_path, full_path, `r, , all
* w8 }1 J9 E  d2 F4 s  IfInString full_path, \9 y# A6 q0 A- t4 Y
  {
0 c: C6 Z8 s) ^' ^9 ?2 g2 E  Run, cmd /K cd /D “%full_path%”' v1 ]# B7 g" J4 A7 n7 t
  }* e& m) r& |9 h0 ]% P* l
  else: Y5 G) J' V- D! E2 D
  {
$ C& G; o5 m7 d1 c$ w, t  r$ `- O  Run, cmd /K cd /D “C:\ ”0 I2 c; K# u3 b9 r' a
  }
* k) h3 A! A2 `0 A- Z  }6 i0 U) E9 U4 o3 C, t
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。8 I: v. C3 q- D! Q3 }
  这段小代码肯能有两个你需要修改的地方
6 ^5 p% z8 e2 ^3 C$ Z2 x. @  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
2 u2 V, H; N% D$ h" w( I  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
% n: X1 e! e% i: d0 U
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-8-17 03:26 , Processed in 0.068153 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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