电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# m  j+ n$ Y$ L. `
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 N% ^8 f! }3 A6 s
  方式一:# F- a/ P9 z! G: k% X  K3 e. n
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
' b. b  N$ E1 S! s% _) H( Q* @8 i  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 T. U1 V$ j/ ?; M  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。% ~: a. o6 e- E8 {
  方式二:3 }4 t- h$ {, p
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( s4 H; S" P+ U6 j5 _  SetTitleMatchMode RegEx% j- h+ @+ |/ ]- v; }
  return% t$ \, g# F  h1 ~
  ; Stuff to do when Windows Explorer is open8 ~8 O3 J6 i3 `7 E- G* N# V0 k
  ;
- C9 y2 j1 C+ _  #IfWinActive ahk_class ExploreWClass|CabinetWClass4 i  o4 L* @( g  J
  ; open ‘cmd’ in the current directory
6 J2 V; X' b# }2 ~8 I/ ?1 n  ;! A+ I, Z& K/ s+ \9 m: Z
  #c::
* O7 C+ p1 \! I( Q' i; F  OpenCmdInCurrent()
7 E- S; h: G( [& ^, V  return
+ h: `2 i+ n, E/ ~$ f* Z+ M) r9 M  #IfWinActive: s3 m. \& P. v% Z9 ^. J+ h
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 ]4 `! J* b4 o  ; Note: expecting to be run when the active window is Explorer.
+ S$ N/ ^( W# v) J  ;/ i% E# I2 h3 |  B2 a
  OpenCmdInCurrent()
3 y7 k) y' L! Y8 f- o/ g% {4 M  {
% Y0 S5 R& e, Q% G* V+ V  ; This is required to get the full path of the file from the address bar
# w/ c& \( W0 u- {8 X  WinGetText, full_path, A
( b& M5 K1 I1 G. J  ; Split on newline (`n)9 o& [6 y5 }& S* V2 i4 w& Z
  StringSplit, word_array, full_path, `n
/ S2 l2 P4 P9 d# @9 x1 d  ; Take the first element from the array2 S$ E5 ]0 B( a& w! F  ^
  full_path = %word_array1%  f# B9 P+ {4 d1 [1 t
  ; strip to bare address
+ {2 |  ]5 W0 h6 H  full_path := RegExReplace(full_path, “地址: “, “”)
! h  j' i% d6 V6 p5 `  ; Just in case – remove all carriage returns (`r), Z: F6 h+ c. K9 ^: @& R$ V/ r
  StringReplace, full_path, full_path, `r, , all8 _, z* R3 M  w( C3 _4 @
  IfInString full_path, \
1 ~4 f7 v' l  T  B, ~  {! V* l4 W: ?; l& B  X
  Run, cmd /K cd /D “%full_path%”% W5 M2 o& B4 Y6 `( v7 D
  }. M. G& o. T8 f2 I3 c! U. g
  else8 {/ f+ o4 }5 M& e9 i# S2 ~, O4 T
  {! ~! |$ K+ G+ E" n
  Run, cmd /K cd /D “C:\ ”
3 M# ^. N- E  [4 T- N5 B  }
3 U' X  u  {2 z0 Z" B0 p% k  }
/ Y7 N; i8 o5 ?3 m  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
5 w; B& P& d7 \& T  K0 i  这段小代码肯能有两个你需要修改的地方
5 d; l! J* h2 k# Y& B  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ H1 T9 o' f0 O: _
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “& \+ [: j9 j, P* ]4 Y
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-9-18 19:57 , Processed in 0.053699 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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