电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 f0 z: P* w1 K# }# X8 D7 J  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
5 p, A' b' x! U& f- e  方式一:0 f# [; F# J. Y: T$ x7 o8 g
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 D0 t; ]: i& k& C8 Q* v: b: h  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 l) R- T3 J# [1 ?; f9 N: i
  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。# c# R/ {/ `* H. \, {1 r
  方式二:
9 M6 |( ]7 m1 z: m3 g  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:  l% {! A8 l2 _' q# G
  SetTitleMatchMode RegEx1 [1 T( I; R) p8 h1 C0 s8 C$ E# b
  return
' _7 d- n4 x& N2 x1 E8 T  ; Stuff to do when Windows Explorer is open
. q7 ?# ?+ N% o, x  ;
7 w, C6 |6 K; k" j6 r1 I  #IfWinActive ahk_class ExploreWClass|CabinetWClass
, M- x6 M* p; y/ e4 D  ; open ‘cmd’ in the current directory5 `% F; f% A; y! ~
  ;% P7 ?( y: W+ A. q7 E
  #c::
1 p' j* i4 u; @) X: h  OpenCmdInCurrent()9 `- g8 c% ?# D9 h( `, L
  return
- ?8 U# a( t, k" T& ~" `  #IfWinActive( Y2 P& A: A2 Z2 v; }) c$ n. i
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.! p8 E6 p' i* s9 ~9 W: ^
  ; Note: expecting to be run when the active window is Explorer.5 H4 [2 r& E3 L
  ;% y3 o% X; B+ ]6 H* o, Q* h# ]
  OpenCmdInCurrent()/ X$ q" b7 j- k  h
  {% d# p5 I+ Q+ M, ~
  ; This is required to get the full path of the file from the address bar0 j& c( H$ o7 E# J3 d
  WinGetText, full_path, A
4 f8 W5 n. e. P3 i  ; Split on newline (`n)
4 }7 @7 W* X* Q% E& o% D5 i3 s/ X  StringSplit, word_array, full_path, `n
6 P! J" R- s  |/ V0 p  h1 X% t  ; Take the first element from the array6 \5 ^$ X+ i! ?! x$ ]8 K+ r$ Z( k0 S
  full_path = %word_array1%
( ?/ ~  {+ l+ j0 }9 W5 t, i  ; strip to bare address4 w, G2 v, @2 o2 _! y
  full_path := RegExReplace(full_path, “地址: “, “”)
/ \  Z. c$ a4 w  ; Just in case – remove all carriage returns (`r)" m' ^8 J* N: r# }
  StringReplace, full_path, full_path, `r, , all- @% _5 O6 s# B: D& e
  IfInString full_path, \
; v- @$ N, L2 C  {
/ Z6 a5 r. b( M  Run, cmd /K cd /D “%full_path%”, W! ^0 e$ o* u2 ?. p4 K" t/ Y0 H
  }
/ Z  b6 k4 [7 I  else' [  v4 g6 ^/ P) _, k8 o
  {7 u: j& R2 R/ f- ^; [( B( \
  Run, cmd /K cd /D “C:\ ”6 D' ]4 I  s& x) |9 j; T; w3 A- k1 T
  }
5 ^( R5 @0 D5 z# n# l  }
0 l& m% C' X! D0 G( z# T( Y: D  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% `& |( S# {& O# v8 C- _9 P9 ?& b
  这段小代码肯能有两个你需要修改的地方9 d* R' a0 J* ~" [  \
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
  P! J/ ~& }& A* y  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. L" y, I0 R( a- s5 ?" ~* P
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-11-21 11:46 , Processed in 0.056034 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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