电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 d) C! q: V& Z2 q7 ]' X- Z
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* H6 P' b3 N( P9 G  j4 w) W  方式一:
0 e7 Z- N8 _1 Y' ~- q- E  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# `, l) l: i$ k- r5 e  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 _1 f$ [, Z$ p% @- U/ l6 x
  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
0 g( c2 n- ?$ o! t- x7 |/ D  方式二:( T: u1 E5 Y  v& G
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ R* I% Z. \+ i3 h' b
  SetTitleMatchMode RegEx  Z# F. D8 m- n' y
  return+ [. q( i: ?2 G0 r+ ~" |5 _
  ; Stuff to do when Windows Explorer is open
; o7 D% i& ]& e2 Z8 R  ;+ ?4 V9 a; n/ ?# X
  #IfWinActive ahk_class ExploreWClass|CabinetWClass
/ f3 l) o# X) H; m  ; open ‘cmd’ in the current directory
# e9 p8 J0 e4 i8 }: O  ;
8 y0 `" B' a3 o  #c::+ Z2 Z1 S" |% q9 }
  OpenCmdInCurrent()
" |# n. q) K2 ]1 J/ g  return
, R( B+ m# t4 e' u4 |9 e& g5 h/ ?  #IfWinActive
0 ?0 w7 d6 r- d9 S9 f% w: b  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 v1 [5 K  v  U( n" Y1 b  ; Note: expecting to be run when the active window is Explorer.; [# J  V9 R+ f# M* W9 R9 z, P
  ;
2 v* D. `$ d+ F: _  OpenCmdInCurrent(), ^+ ?/ Y3 _! I
  {
% H  J$ f' P/ r8 r4 v2 [6 _5 v  ; This is required to get the full path of the file from the address bar
# z0 P0 m, W8 S, v9 D6 y( c/ |  WinGetText, full_path, A3 Y+ o: I2 r5 t; r6 r; P4 A! ]
  ; Split on newline (`n)& x8 y7 O5 Y% f' g* `: |+ P
  StringSplit, word_array, full_path, `n
0 Y" \* s: W( a5 g, e6 R  ; Take the first element from the array  \. n: `% J/ Y
  full_path = %word_array1%
: b5 \4 D2 N9 M6 }. H  ; strip to bare address1 i, n: L* G! ^, m
  full_path := RegExReplace(full_path, “地址: “, “”)
- _8 [2 ?+ |! ~7 m: C  ; Just in case – remove all carriage returns (`r)9 U$ h8 h& J9 c/ z
  StringReplace, full_path, full_path, `r, , all1 g0 G. X$ |- t: C8 a
  IfInString full_path, \, W! {- \0 Z; \4 h  _$ N6 S# }  O
  {5 T; \) i/ Z0 F! \3 S
  Run, cmd /K cd /D “%full_path%”
. v; P: V( {# G  }
' Y- {  p, O6 t6 X  else
& l7 {1 W- v* J. l  {5 T  Z8 e0 w3 O- h" ?/ v
  Run, cmd /K cd /D “C:\ ”
7 d5 A1 ~6 e2 y# h  }. _. n1 |1 A( u% P
  }/ d, |1 w. Y' I8 Z! Z8 k
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
1 d; @: \4 ^$ J/ w  这段小代码肯能有两个你需要修改的地方
1 g9 X, V. Q( I( M; j0 y+ Z5 U  u  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- ^: z  A) A' o$ _5 N  ?  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* b7 K+ G" O* u% I, H
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-3-29 07:54 , Processed in 0.054091 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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