电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 f3 W0 s6 T6 `9 A  M  ]. J9 R1 Z  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, [: ~( n8 {' q" f! S' L! n
  方式一:
8 y, k1 t# K  K  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 S' S$ ~& i3 u4 S- G: x
  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
  Y! Z1 c5 t2 z2 K( `6 t1 U  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 Q. A% }( V+ E  方式二:7 z- A+ e2 C9 l' \: m% k
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
0 y, [# ?0 F7 p" O5 D1 [* ?  SetTitleMatchMode RegEx
! M2 R& f* [, o  return
" J- P  Z* ^8 X0 S8 [2 l  ; Stuff to do when Windows Explorer is open
+ _) s& ]  }+ L  ;& [1 H: M3 }( x0 Y
  #IfWinActive ahk_class ExploreWClass|CabinetWClass# L$ {; i/ _7 N2 e
  ; open ‘cmd’ in the current directory
0 ?& f9 @1 r. @4 p' K  ;
$ ]" N( A) A& O$ Y4 e/ v! t  #c::/ H) t7 J0 H7 {( C( G2 J# R
  OpenCmdInCurrent()1 x9 k6 G: V  T( ^
  return
2 b; W- ]3 P6 h! a8 G6 w  #IfWinActive
0 v2 J) ~, Q! w; K- @  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 i; f, S! H5 O+ ?: h) O6 a$ o  ; Note: expecting to be run when the active window is Explorer.; w$ H+ U4 V" K+ y& b
  ;$ w( ]2 E$ t( N
  OpenCmdInCurrent()0 i( {2 N  U7 j* B
  {
2 a- n: w+ l4 h6 K$ s; h9 Z  ; This is required to get the full path of the file from the address bar
8 j0 Q8 m1 X# z  WinGetText, full_path, A7 a9 m+ A& Y* j% i% P5 V
  ; Split on newline (`n)3 J- r$ {; h9 O4 e
  StringSplit, word_array, full_path, `n
8 d$ R' R& ~. H" |; @# F  ; Take the first element from the array
0 j" c+ x- x7 {3 z/ \. n  full_path = %word_array1%
7 O  i4 a; x, U7 x9 K  ; strip to bare address
8 j, F* V. Z/ u& L$ t  full_path := RegExReplace(full_path, “地址: “, “”)
8 t, ]5 M! W* J- O# |# K5 m  ; Just in case – remove all carriage returns (`r)1 h: K, M3 |# F& R4 S( b& U) G) C) }
  StringReplace, full_path, full_path, `r, , all. a: S* e+ s( p8 J
  IfInString full_path, \
& O( X& v  ]8 A0 g8 w% }! i) M  {# @$ a' N* }& f( X% w
  Run, cmd /K cd /D “%full_path%”* z4 N' s" N: V( @- m7 }
  }7 G2 \7 J4 @5 I
  else% B0 P8 D0 }: [2 o9 C) }) T6 S* Y
  {/ G' ^6 _$ W+ `5 m6 _1 t
  Run, cmd /K cd /D “C:\ ”
4 C3 X; m2 f! M+ I  }8 n- C3 x3 o$ K- d& k- L! y  |
  }3 A# c1 n) m3 U4 n6 i9 a2 ?  O
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* U7 P& e2 h6 R7 {# q" d/ P% o1 W
  这段小代码肯能有两个你需要修改的地方0 \6 g# ]4 z: P% Y5 L$ s: y& H* E& W
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键1 Y3 m% [6 n" R7 B) x
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “& r9 l- u0 U2 z$ W3 r: `( R
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-11-5 09:11 , Processed in 0.057144 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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