电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
/ e) y! \) Y  ~# |& H! ]# S  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ g% f1 h! @3 Q/ X$ k
  方式一:9 y- C3 d' F% ~* t
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
+ P, x' w6 }" h, q5 W+ q. E  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 T. i5 w0 A1 J7 S/ b  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" f9 P' x% N6 k' e: ^1 W( i" k
  方式二:$ F* ~/ S4 p8 ?# u3 |8 l; H
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( q7 f) f6 S0 i/ J" _4 @  SetTitleMatchMode RegEx9 c6 E$ V+ P3 k" g
  return% A( i2 C8 n  w7 T- n3 j1 u' L; [
  ; Stuff to do when Windows Explorer is open
2 T9 R+ a, n3 b' B; T  ;
1 \" @, w) q) t7 X7 c4 C  ]2 s  #IfWinActive ahk_class ExploreWClass|CabinetWClass5 O0 m" \4 _" Q! D
  ; open ‘cmd’ in the current directory
3 @5 t% v+ \; w  ;
6 F9 `1 G; @7 d" w, C4 ~# r6 ?  #c::/ H  u' t9 P6 f( y& h5 v4 {
  OpenCmdInCurrent()/ `: f/ n: H# q4 `" @
  return& [  k, l2 ?# N
  #IfWinActive8 |2 G6 h, y: q1 P' ^
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% p7 M0 D& z. X  ; Note: expecting to be run when the active window is Explorer.
% u3 f' t4 {  M1 y' T) q  ;
- F/ d& \; {+ ]1 ^, c& q( L- j  OpenCmdInCurrent()
+ a" \2 u9 M8 T9 \$ b% U  {
1 h; y) O9 J4 B) ~  ; This is required to get the full path of the file from the address bar6 l& `, V+ P5 e7 S) a' z  w
  WinGetText, full_path, A
9 u! o8 [- V' f8 O  ; Split on newline (`n)
  N7 K" i- R- `. R- a  StringSplit, word_array, full_path, `n. L  @" f7 ^$ B, y
  ; Take the first element from the array
0 }% u% k+ j7 Y4 W( s  full_path = %word_array1%/ ^0 ~! h0 `. {/ V9 z
  ; strip to bare address
% {* p1 ~( X: b: @' D6 c  full_path := RegExReplace(full_path, “地址: “, “”)
5 {/ A7 w# x1 x1 I. }  ; Just in case – remove all carriage returns (`r). K& q! L+ u8 c* C: X5 O
  StringReplace, full_path, full_path, `r, , all
) V: a7 C* e# @1 b+ l  IfInString full_path, \' V: D3 n+ I: K
  {
& @2 r6 {. ]2 a1 O, u% p3 `. {  Run, cmd /K cd /D “%full_path%”" l* k) _& j1 A+ W
  }8 X5 E- Z( [9 ^8 C
  else' Y& W; h6 d5 e& T9 e0 t. ~
  {- w' A! J% }6 l0 y( z1 n8 D
  Run, cmd /K cd /D “C:\ ”
  R5 O. A+ G- C# w  }
5 v: s. X0 i" E/ ~5 x; r/ _, M  }
% X0 y% q3 k4 ~( s2 t" R  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( d# i# e/ C; d  C! M  |2 Q8 {
  这段小代码肯能有两个你需要修改的地方9 y" C8 g- d5 C2 I! C
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 a% c' R& M) Y9 [4 C% C4 u  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! z, E, L* T- k
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-11-18 06:18 , Processed in 0.054366 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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