电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
4 s- w) A3 E, A2 x7 y  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ v. M, G0 j( J2 k: V: |
  方式一:+ j5 ]0 G1 e, K0 W4 W
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,! c- c) o. m" C
  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和- X0 N' Q% o% K" l5 ?1 ~3 o+ E* d
  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。  K6 r& ^' {4 K! j  Q% r! O8 `; _
  方式二:
% Y& O/ e  r- D  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! A  J- v) a( a  _* A- F( v
  SetTitleMatchMode RegEx- I/ i  d- b% }3 w
  return
9 P# Z; i# |/ P% U8 Z" l$ b  ; Stuff to do when Windows Explorer is open2 q0 S. h2 g- w: z% x8 F, Y
  ;4 N+ R$ W2 A5 r7 T: n/ V
  #IfWinActive ahk_class ExploreWClass|CabinetWClass- J6 B0 B8 {* X7 s$ a- W
  ; open ‘cmd’ in the current directory* g) }2 W: R6 u4 i, Y7 K# [5 F
  ;; V/ G' K+ ]5 B/ e' T" S0 \% U2 _4 D
  #c::1 q! f9 K: i* g9 r" D( S
  OpenCmdInCurrent()
! |+ e! \" l) z  return5 n4 d& d  @2 X) {5 D
  #IfWinActive
1 `; R5 a) o0 B( w' \  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- W* ?/ x/ S& c2 _2 x, \  ; Note: expecting to be run when the active window is Explorer." x1 L+ K( s) c
  ;, ^0 s4 C4 {; Q) r8 o
  OpenCmdInCurrent()
) v' h; L( A& X5 p9 l  s7 m5 ^, J  {
8 j/ A" w4 q1 X& f  ; This is required to get the full path of the file from the address bar
+ W% E* V! [% {6 @! K, ^4 H  WinGetText, full_path, A
, r, j# w- z) @6 Y/ O  ; Split on newline (`n)3 b9 s; x! s) ~" K( _; P% b8 T
  StringSplit, word_array, full_path, `n
* ^! h) ^: z& e/ v  ; Take the first element from the array
5 Y1 z- N/ F7 c$ r$ I& y  full_path = %word_array1%% ^, L2 a1 _. y7 J4 ^1 c3 O+ `, s
  ; strip to bare address
: A$ Y: ^. z# r% m  full_path := RegExReplace(full_path, “地址: “, “”). n6 \" \$ e8 ^5 }. E. e/ A1 V
  ; Just in case – remove all carriage returns (`r)  |7 O) r1 O9 N, Z
  StringReplace, full_path, full_path, `r, , all
6 z$ U2 I  h. r. L& M  IfInString full_path, \
4 w! o; t! g% ^& e  {
$ r9 S2 C: `+ {  J4 k- X4 i  Run, cmd /K cd /D “%full_path%”( T7 J: W. O/ X( i, K
  }
% o! b. ?+ Q2 i" z2 c$ v7 b  else
' B) B6 H9 x. k6 `2 [3 K  {
5 L/ m" r% t  ~1 D% K  Run, cmd /K cd /D “C:\ ”. o& J, X4 g8 W
  }' u! b1 I0 {4 A0 `* k
  }
8 y& c8 u$ ?7 f  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* W' ]- \9 \& I. h3 ]8 P8 e
  这段小代码肯能有两个你需要修改的地方, f$ g' w& L# l
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
* R$ m7 q- `2 s. s# ?" e  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! u/ O# M# ]$ ?6 h. ~
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-12-29 16:34 , Processed in 0.056201 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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