电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 G, \6 q. P3 X, j) Q9 M8 m  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! S- h0 k, x1 `3 X) P7 Q7 o; @
  方式一:
2 p  d& _5 Z1 t! F. b  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 a. A, N- f2 `- |3 [" M2 [; Y
  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, N4 }" z$ h$ E3 S* x" A- c  Z& a, i  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。& n5 ]5 k, |1 u
  方式二:
- x5 f8 t( Y# }  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
6 Y" s4 k( n- e1 u  SetTitleMatchMode RegEx
" R6 L; B8 a! P7 ^! a8 S  return
3 @3 l9 a! {) ]& i6 |, _  ; Stuff to do when Windows Explorer is open
, j- O: J# r% G  ;! x8 o* g! M4 Y5 K
  #IfWinActive ahk_class ExploreWClass|CabinetWClass
$ U7 V# o: V9 [& B" {7 ]2 |  ; open ‘cmd’ in the current directory9 ?# P+ P2 }6 l! k* ~8 R
  ;
5 j- q2 r5 F; }  #c::
1 F6 T0 w7 n+ {0 r' f" Y) Q2 }  OpenCmdInCurrent()) O5 q4 t" R  O1 I
  return6 c8 o  U3 ~+ `# ~$ g! m9 _
  #IfWinActive
: j+ V, T6 O9 U  E  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. ?3 J1 X/ r3 K# j1 y  ; Note: expecting to be run when the active window is Explorer.
$ M  e& ]  c3 S7 ~. N4 x  ;
8 r+ L% N4 F* ~9 a2 m) f4 X  OpenCmdInCurrent()0 k0 E2 z2 k# B- [# v
  {
+ F2 f6 O' ^1 t+ N5 x  ; This is required to get the full path of the file from the address bar
% }: F, b7 E( Q  WinGetText, full_path, A6 E1 O* w1 x) z+ m. e
  ; Split on newline (`n)
2 ^- ?/ ?- o- j! C  StringSplit, word_array, full_path, `n7 a9 }5 o1 r, g% y
  ; Take the first element from the array
5 r6 H9 ]8 ]- K* H" v  full_path = %word_array1%! W- l6 g# V+ z- u! o6 P
  ; strip to bare address& t1 o! d: u/ V% w
  full_path := RegExReplace(full_path, “地址: “, “”)2 c+ E1 ~# ]1 z4 M
  ; Just in case – remove all carriage returns (`r)
/ j0 o+ R1 u$ C8 k/ w2 O* K$ I  StringReplace, full_path, full_path, `r, , all# g! @; L- N/ P0 S/ p8 b
  IfInString full_path, \
) i% M" R. @$ t$ @6 ^* c  {
+ X, ]- F, ~& e7 i2 g3 {  Run, cmd /K cd /D “%full_path%”* D* }* u, m% m- b6 L% u
  }1 _! P$ V$ w. G$ K2 B3 i! X0 u
  else
  ^) V! R3 C. @0 F  {
3 A6 C; F8 M4 Q9 t, K$ `3 ]  Run, cmd /K cd /D “C:\ ”
! Y( z: p& d8 W  }
5 S# E* I& V8 ~  }
/ s. h% A% q5 l* F  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- n2 a# G& u  O0 E) s  这段小代码肯能有两个你需要修改的地方
' x$ s: a5 Q( g+ k8 J. @+ R$ _  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键! m) B9 q2 T' L2 F
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( Y7 v. B  O5 o" J4 c4 m
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-6-20 18:26 , Processed in 0.069166 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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