电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& @& X) O& W+ w1 D
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. s: @/ R, Y* X8 Q3 O+ q  I" M
  方式一:0 b6 t0 G' T: P
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 c3 u3 Y! d1 r9 f
  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和& b1 [" |3 O" k
  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。; t1 i4 G& E7 W/ q0 |5 e
  方式二:
7 W- |4 W* F. W, e8 i' o/ j0 `  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
4 b( g- |7 W2 J* C  SetTitleMatchMode RegEx
4 y  \$ Y/ u% H/ J5 Y( @  return
4 @# ?8 F' h7 A3 w7 z  ; Stuff to do when Windows Explorer is open
0 O  a! _* l5 C  ;1 j8 a0 U/ W6 }7 {2 o
  #IfWinActive ahk_class ExploreWClass|CabinetWClass
* q( I& d# P9 ?8 c0 Z' Q9 Q  ; open ‘cmd’ in the current directory! A8 S  T% Y' s1 Z. v' E
  ;
2 c& v6 V3 m+ @8 i' i  #c::8 e$ A3 ^6 i# N- o! @
  OpenCmdInCurrent()
, {9 @. [3 L+ r: m/ x  return# _" h' C0 Y9 a7 u2 c! X
  #IfWinActive
& ?6 o9 m' `3 f& V/ a$ m$ N  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* \. k4 a, I3 P% u  ; Note: expecting to be run when the active window is Explorer.
$ H1 n" ]* @( o- l+ L2 x' x. E' T& B  ;6 V. u0 j3 a/ Q% L, N* G
  OpenCmdInCurrent()
! a2 d5 p5 i$ P  {
3 V5 [9 e# t% L+ d# ^" n  ; This is required to get the full path of the file from the address bar
' ]5 @3 Z7 w  e" D  WinGetText, full_path, A
2 b/ X9 `7 e( ?7 e) J  ; Split on newline (`n)
- h3 t; O2 E1 {- c9 ^8 p  StringSplit, word_array, full_path, `n' o$ r$ Y1 u- C) J8 q
  ; Take the first element from the array
- {8 ^: x- O8 x- o% Q# w5 e  r/ `  full_path = %word_array1%
& s+ r, M" d" ?0 Y/ j  ; strip to bare address
+ V+ b8 u3 Z2 W  full_path := RegExReplace(full_path, “地址: “, “”)
+ m( v( I$ [& g( ]& ~5 q  ; Just in case – remove all carriage returns (`r)0 j( w% d! O& d
  StringReplace, full_path, full_path, `r, , all
9 {4 A  {- H. ^4 a$ X6 l  IfInString full_path, \
0 U+ ?$ u/ r" {; f- \0 F8 g  {4 D/ N4 O* X0 a/ g
  Run, cmd /K cd /D “%full_path%”/ n, Q" B+ x1 E2 r
  }0 y2 e6 H: A# k' |3 E' i; R
  else
2 U1 j" o1 l7 M; Y6 g  {
& `" k. x9 t: p; `: j- b+ b  Run, cmd /K cd /D “C:\ ”
( x. n/ H9 \- v5 p  }
" g' _1 s3 S: E' b4 J& c, V  }9 [1 y+ ?; |  D( E6 n! G
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" Q7 c$ ~( N. j' j  这段小代码肯能有两个你需要修改的地方
4 X9 R( @3 P1 L9 E* k, l! w  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键/ e$ e* ~5 f- p
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
( H6 ~* W5 U9 u
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-12-3 12:58 , Processed in 0.077472 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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