电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 T: r' _" P/ d1 ]  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 l# i- t$ [" s" N. G  方式一:  H# L1 b* Y& t/ o% V0 @
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
; q; J. \, v, M3 J3 R  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* L3 k, x2 M* d
  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 d: w' K/ l8 e8 n! @, s  方式二:( ^, q% \7 m/ Q( T3 g3 H; T+ q/ S
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:0 V  t6 I; X$ o# L
  SetTitleMatchMode RegEx
5 V9 K! k) m) z9 W  return7 ^( h! T  }! P( O
  ; Stuff to do when Windows Explorer is open+ a7 g' s: {% D/ x) k' b
  ;1 h7 z$ z8 P- @0 D
  #IfWinActive ahk_class ExploreWClass|CabinetWClass6 X9 m- N8 p6 G4 z4 A
  ; open ‘cmd’ in the current directory
: s* [# C# d( r# I: n  ;
8 I  J6 D- [) s! T+ t  #c::: E0 m, \- J3 u/ |' N  L# L3 H
  OpenCmdInCurrent()
. c, x2 y/ ?$ K' l  return
3 b2 `1 `% j/ ]" D1 g) X  #IfWinActive% {$ o( W9 B4 }4 g6 T
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer." m3 O' T4 g" Y0 a# N
  ; Note: expecting to be run when the active window is Explorer.
7 P  O+ _7 M" w7 M  ;% q) v, Z7 W1 u+ K
  OpenCmdInCurrent()2 d8 R% D$ T, R. X# X$ \, w
  {
. Z$ h) ]) K# E# ^, q  ; This is required to get the full path of the file from the address bar
6 O& K* Y. O$ u  WinGetText, full_path, A: R% ], e  T/ i) _
  ; Split on newline (`n)
% e7 I& T7 n7 _: l  StringSplit, word_array, full_path, `n0 m4 Q6 W6 q9 N  ?! u0 \
  ; Take the first element from the array$ H& e) {0 r0 ^/ I, b8 k
  full_path = %word_array1%
6 P( b5 b. `% o+ s7 ~: O& W# E  ; strip to bare address2 n+ _# K/ ]2 a/ F; }
  full_path := RegExReplace(full_path, “地址: “, “”)5 r, u! w: j2 g" X) z" Z
  ; Just in case – remove all carriage returns (`r)5 d$ x8 O4 \9 c8 E6 @( S
  StringReplace, full_path, full_path, `r, , all
$ s7 s+ |! S! o8 Q9 \0 a2 t  i) [  IfInString full_path, \
1 V+ j8 w! y$ k2 d& g) i  {
6 f" W5 l; U5 Y! b% L  Run, cmd /K cd /D “%full_path%”4 e) {$ q$ n+ N% h
  }7 S' z5 b; w, k' e3 l9 m
  else& w1 @2 F. b0 p4 `, ?; V6 @) q
  {
# R2 g/ T# Q! ^  Run, cmd /K cd /D “C:\ ”: S" m2 ~* Y* Z9 B' \7 q! U
  }
) D6 E& `2 i" t0 o( d* z  }+ M; a4 w2 K2 H, a" ]
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( Z0 g6 p( m" v9 @2 k9 L
  这段小代码肯能有两个你需要修改的地方8 {: L7 a! R& U* z- I5 P
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
2 X! I! y0 B2 U! v- _  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
( ~0 p' n6 s6 C! ~! q$ L0 z
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-12-20 06:04 , Processed in 0.090536 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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