电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ N9 u4 W/ j5 b) x9 j2 {3 h5 i7 r
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 @2 ~) ]( x  ^! Q# q. r3 ^3 y" o  方式一:- g$ S5 u- |7 V4 C/ x
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( A/ d2 |  F! D- Q  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 \5 m( G" q! m/ s0 Q* ~, E& ^
  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
# v$ R9 \9 o5 W: J5 Z$ C6 _  方式二:8 G) Y& k4 g$ v) Q
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:8 f' y! F4 |: C- m+ _) Y- s
  SetTitleMatchMode RegEx
0 N+ M3 n# K4 e  return+ s2 F" r# W* g! ?2 a
  ; Stuff to do when Windows Explorer is open
" R7 J! w( E9 B  ;3 m3 j7 k- C- |& A' l* w
  #IfWinActive ahk_class ExploreWClass|CabinetWClass
3 B1 I3 k- u! J& N9 H/ N  ; open ‘cmd’ in the current directory! _8 H# A( i8 }1 E
  ;
! S: h) J: T& i% O& b7 }" N  #c::
& d& W; P+ J: {, m  OpenCmdInCurrent()
6 Q8 B8 e+ ^/ R/ G4 R) i  return( H# I% U1 W* c* U+ `7 ^
  #IfWinActive
0 G6 h3 {" W9 K) A, z, s8 w) Y  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
$ p7 m0 X' i; k  ; Note: expecting to be run when the active window is Explorer.9 ?2 v) f! e! {6 U7 d+ t
  ;8 q3 @# d8 X% G4 B- a) u6 f* i
  OpenCmdInCurrent()8 {* |/ e5 h; a# a
  {5 Y" f0 d1 [! P0 ~" [
  ; This is required to get the full path of the file from the address bar
5 d  ]* U; j/ X8 @  WinGetText, full_path, A
/ x. J! Z: j9 O* V# G0 s6 [; \3 P6 ?  ; Split on newline (`n)
% P( {; t9 A4 o" n  StringSplit, word_array, full_path, `n1 N3 Q% s7 D+ @) J% Y
  ; Take the first element from the array7 A3 {, j+ K$ l; t
  full_path = %word_array1%
) _- ]9 g* n9 c  ; strip to bare address
, u7 N+ [/ a. I5 @0 A* u+ E  full_path := RegExReplace(full_path, “地址: “, “”)
- x  T- s. z# q7 r  ; Just in case – remove all carriage returns (`r)
( |$ ~+ t$ j; @0 Q5 [  StringReplace, full_path, full_path, `r, , all
$ x% q  f/ p0 }+ ]+ Q" s  IfInString full_path, \
& o$ s+ n3 O! L5 w5 x4 ?  p  {& C9 x9 P$ O6 E8 D6 A1 O
  Run, cmd /K cd /D “%full_path%”
8 g6 u$ ?; g( z- X% _& N( H7 t9 ?  }. q( I( G8 X/ d
  else" ]; e6 s( T3 ?
  {2 C  \1 k" O8 o  ]
  Run, cmd /K cd /D “C:\ ”
/ W" X! L( H5 f, N+ c9 f  }. j  u$ Z! U' U# B: Q
  }9 v: L  r% f# H/ ?' b% l5 }
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 i8 ^! b" }) I% p) @' r" q  这段小代码肯能有两个你需要修改的地方
' S1 d  _) M  s3 ~% |! p! u  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& s7 A9 d! A: x, ~( D  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, @; l  @  X; \8 T" m& I
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-5-13 08:34 , Processed in 0.055462 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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