电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' K3 ?/ v7 j- @1 b& i3 j( y+ `& F  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 m; R" G* F2 B8 d! L  方式一:
  [5 z: q( [  Y% K3 y" U( k  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. d" |3 S% f: y
  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 P" }- Y7 V6 k3 n" R! y: _  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' `0 t  w  s+ g  j  P4 @* m  方式二:
$ ~& i5 i9 \, H# Y$ a  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
: I% f) y4 ?3 Y  SetTitleMatchMode RegEx
* [) ?8 w0 M, W9 l  X  return
2 _9 f! m9 A( `  ; Stuff to do when Windows Explorer is open
" x5 }. b2 X0 j; K5 A3 j; F0 f5 Z5 d  ;/ ?2 `4 f" |1 }! h, p
  #IfWinActive ahk_class ExploreWClass|CabinetWClass& {9 a7 N2 \% r( ~% w# m
  ; open ‘cmd’ in the current directory/ y; _- j5 `# i' s
  ;3 ?+ e9 X/ ~) L
  #c::
6 T- j$ r( y: B. N  OpenCmdInCurrent()
/ ^" P8 [. h( ~' t+ |& z$ V- w3 d- u  return
" Y1 ?! Q  t# b" R  n; c  #IfWinActive6 I% t/ Z5 }: L, B) y
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 r1 K0 _3 S: m' Y$ x7 a$ n
  ; Note: expecting to be run when the active window is Explorer.+ U& Z5 w0 _% r9 a. N. a
  ;7 Q+ u8 ]9 y1 S4 W3 A6 v1 f+ O
  OpenCmdInCurrent()
4 b$ Y. O9 e; m  {
! r; G: C! \% x2 |4 a1 ~  ; This is required to get the full path of the file from the address bar
6 T7 U0 S, B5 A" ]- _+ e  WinGetText, full_path, A( v( m& l7 q4 H- L& k
  ; Split on newline (`n)# A6 j* k0 K) F
  StringSplit, word_array, full_path, `n$ F& k" z+ h: `% l2 r7 U+ y
  ; Take the first element from the array  x% R0 ~8 N( T5 |2 Z4 I. ]
  full_path = %word_array1%. \3 B4 w. n0 s5 I) }6 x5 R& l
  ; strip to bare address( r, p* c; B& S/ `* s; Y
  full_path := RegExReplace(full_path, “地址: “, “”)
1 r. N+ h. h' H: [# U' k( r; O  ; Just in case – remove all carriage returns (`r)! d; t9 V( `: a9 _+ }
  StringReplace, full_path, full_path, `r, , all
  F* F% z. a$ _  IfInString full_path, \
! a5 D$ `2 h  T  {% M0 h. v5 h! y' h
  Run, cmd /K cd /D “%full_path%”
- k8 V- G8 P. \4 l2 _  }
3 G' C  p8 I! c7 H1 F4 a  else
" \4 m' D3 ^3 h0 R' V# I. ]  {
8 q6 U, A( p$ M' {, u  Run, cmd /K cd /D “C:\ ”
" P/ t! W, {/ I8 I  }/ N$ V0 J4 X( ?5 L
  }/ X3 z5 O9 s2 e0 x+ A: }; `6 c* F8 C
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。8 D; v8 M8 h( W  A$ o
  这段小代码肯能有两个你需要修改的地方
+ R4 [9 s' v6 \; I  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键  `  s- a* I5 J
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: V* U/ O* {5 R7 q5 N$ }' p4 x
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-7-12 08:07 , Processed in 0.117237 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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