电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
! {% W( @9 o) ]0 Q  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
  X3 j$ e! q: j9 C2 n' `$ Q4 m  方式一:4 }  m; b1 O1 v% f! t$ }" d; u
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 L0 L: {) s+ T5 @/ E1 P( _3 t  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! T0 K4 q" D  Z7 a" c: i  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ Z1 [  J, A% Y5 ^  方式二:- c: m4 U3 s/ U/ n
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
6 o' w9 _: B- @  SetTitleMatchMode RegEx; q# E( {, w0 }% u
  return& a. X3 B2 w: w+ h1 o4 w0 Z
  ; Stuff to do when Windows Explorer is open; P& a( }- ?$ Q2 G5 m3 ~$ L
  ;8 r6 _. l7 l( A
  #IfWinActive ahk_class ExploreWClass|CabinetWClass7 z) r; V; z' J% X" w: o2 E$ ]0 P4 _& X* S
  ; open ‘cmd’ in the current directory; s4 d2 `4 b- p# P0 `
  ;
( s0 u- C4 K# a1 a/ @. k1 m  #c::
' W  b. o- ]" |$ t  OpenCmdInCurrent()
- g' C6 t3 g3 [% A  return- q$ ?$ I# E. n& |
  #IfWinActive4 f; I2 X. J+ Z% t( q
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 @4 I* @6 |8 O8 N
  ; Note: expecting to be run when the active window is Explorer.6 [+ M& O$ W1 l/ P
  ;
  r% x, y/ ~3 _2 b  OpenCmdInCurrent(). x, D8 y! j1 R* X! R9 t, }
  {
1 J2 t8 }1 N& `6 \) @  ; This is required to get the full path of the file from the address bar) I2 Q1 S5 y% J
  WinGetText, full_path, A
3 N  V- Q9 J3 Z; n  ; Split on newline (`n)8 A: k( }" G8 i3 W
  StringSplit, word_array, full_path, `n
+ m3 Z, \' Q/ Z  ; Take the first element from the array
& u2 M5 L8 q' d" D. y  full_path = %word_array1%
; ^1 Z! S% ^" B% o9 a+ l  ; strip to bare address
8 n: i" M  d8 S9 \, c% T$ r  full_path := RegExReplace(full_path, “地址: “, “”)
6 g, v# g6 g/ o! S8 m  ; Just in case – remove all carriage returns (`r)* e7 X/ `$ a& @8 |. T0 K
  StringReplace, full_path, full_path, `r, , all7 @; g- P1 a0 u0 U5 A( e" @6 e
  IfInString full_path, \+ N1 c- |/ c0 k( c0 Z! a
  {% q- l. \. U* {+ b6 ]
  Run, cmd /K cd /D “%full_path%”
  E( V  F" N9 A% O  }
4 b  M2 Z1 @0 j1 _% s: t& W; R  else3 W2 d  a' h6 N4 ]3 g( O" \- Z
  {# N* {  A8 h: B; ]# q- v
  Run, cmd /K cd /D “C:\ ”& k8 [8 d' R+ W1 w" t
  }$ [8 O& l8 Z. k' q: B9 z- L6 G1 Z
  }/ v$ S& {8 W0 Y) V* `" i) ~5 V6 N
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( z% G% l% T( e  这段小代码肯能有两个你需要修改的地方+ K3 q9 n! _$ P1 O" X1 \+ h
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- d0 y- W+ n1 L5 {
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) M0 ~; i# w/ ^1 c
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-11-27 06:01 , Processed in 0.108211 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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