电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: P6 k5 M$ u* y4 i" W: p
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
/ h% G1 u( l! I3 G$ u  方式一:1 s/ s; k5 P( [, o' N% U
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 |, Q5 Q+ _, A0 s4 n7 K! m1 ]) G  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
3 @9 n5 `, K1 a$ F% h  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ z* y+ v6 i2 S7 D# a) F; F
  方式二:
# p8 w& {' Y& S$ P2 q9 a# G# m  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 p. H9 f! d% t: G; C  SetTitleMatchMode RegEx( d5 |8 u/ M" U; |7 O: y+ ^
  return
% U! J& M/ c& ~4 i  ; Stuff to do when Windows Explorer is open. x9 Z1 r$ n6 a( w1 |" L, c
  ;
/ W9 ^6 H& L3 Y2 e7 K, A/ E  #IfWinActive ahk_class ExploreWClass|CabinetWClass1 E7 J% Z! d( }# g% a! b9 c9 z
  ; open ‘cmd’ in the current directory6 F# R  E, ]- }3 g' h3 W
  ;
6 K- g# N- R: u) v) P  #c::- Z( X" @4 \0 M+ Q( r# v
  OpenCmdInCurrent()
7 [1 C) m- V/ Q. Y+ ?! }  return+ R5 {% q# ^4 _  U9 H
  #IfWinActive
" d0 K1 e  U3 t$ q' _1 A  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* T' Z; m2 ]& Q) t- ^+ ?
  ; Note: expecting to be run when the active window is Explorer.* G8 m# d% z. W7 \
  ;0 h) v6 K' h4 \: b
  OpenCmdInCurrent()7 l! j4 V* r2 B9 L, ~1 w- G& i& m
  {- {( }9 U/ E4 C
  ; This is required to get the full path of the file from the address bar
9 D9 v2 h7 y2 |( _  WinGetText, full_path, A8 W+ m- A; U+ K# G
  ; Split on newline (`n)9 v7 v- J, C; w1 B: Z2 ?8 d; M
  StringSplit, word_array, full_path, `n
+ v/ t; V# T: J9 ^/ i  F, }  ; Take the first element from the array
6 N4 B/ C  ~' o) W  full_path = %word_array1%4 H& F+ i) s6 d6 s; |1 y8 u
  ; strip to bare address
4 a& \; R. b+ E2 ^  full_path := RegExReplace(full_path, “地址: “, “”)
  u1 F3 X0 z$ a. p; Z& @" B  ; Just in case – remove all carriage returns (`r)! A$ U% e) \0 _5 D; b* t) ?
  StringReplace, full_path, full_path, `r, , all2 o+ e$ T- A. x) c0 @6 f
  IfInString full_path, \* Q; l' L4 V6 b; w
  {) z9 z) O* C: t( ?$ J1 \- e' w- \) L
  Run, cmd /K cd /D “%full_path%”
0 a( T* o7 d/ B0 P- f  }
% L3 c/ E8 J1 t" F: G  else
* k' r9 A# Y3 s, l  i* p* m5 e' K  {
  \. Z- l5 h8 K  Run, cmd /K cd /D “C:\ ”
5 @% l( m6 a! ^9 x  }
6 ~& {: U5 I, }+ b1 W  }+ ]7 t3 l' \; I
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 r! U0 B  f( m
  这段小代码肯能有两个你需要修改的地方4 S" N, u# B" d4 V% L
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' R2 W% [5 V- c- W  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 d. {  N8 o0 @9 P+ l4 \
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-12-27 17:09 , Processed in 0.055261 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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