电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# o% l2 B6 W) F, o5 ~* J
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: q( |+ n& w+ D& ]# b* U0 s
  方式一:
' m3 v* _! L/ Z* e0 l  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 _* Y' i0 Q" X4 p. k) V; r  U  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
% p3 Z5 O+ s4 w8 L  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) A+ C- J2 w% P+ S4 d' F- [  方式二:
4 n" v5 ~2 h4 M% g- k4 [  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 J" y9 q0 A3 g# U* `  SetTitleMatchMode RegEx" f7 a6 X. m  i" q/ x
  return
' E; ?  c7 i: Z/ C& T. s# O  ; Stuff to do when Windows Explorer is open$ g: ?- |5 T+ ], N
  ;
) q; _; L: o# I0 [  #IfWinActive ahk_class ExploreWClass|CabinetWClass
# r6 G8 F% ]" K: S  ; open ‘cmd’ in the current directory: t! [* {( G( f8 Y0 ~3 _
  ;
; u* W1 F* [& F; B  D) E  #c::8 }/ N. d8 r- W3 x
  OpenCmdInCurrent()# u5 P% u& s/ K7 h( X- L7 p2 _
  return
' r/ }) k6 {+ e  #IfWinActive, e1 f1 h5 n, I2 g& ]
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ c) i0 L- t5 I' @/ @  ; Note: expecting to be run when the active window is Explorer.
, A% }2 b5 r2 I8 [  ;
$ S: B4 l3 ~9 B4 ?: p! b  OpenCmdInCurrent()# O& K* Y/ Z' Y! k3 e
  {0 N) i, O; \' j9 Z' ^% E4 e
  ; This is required to get the full path of the file from the address bar7 g7 Y7 L; D( o& {% A
  WinGetText, full_path, A
; s& D5 |+ q3 |2 b* ~* E) V* Z  ; Split on newline (`n)
3 ?' u2 r) ^. @0 \8 k: F( l  StringSplit, word_array, full_path, `n# d7 g  v3 N0 u
  ; Take the first element from the array0 {6 }* M' u# x7 T( l1 F
  full_path = %word_array1%1 H" w; }1 [" R, U& _
  ; strip to bare address. X7 L9 P" a+ N
  full_path := RegExReplace(full_path, “地址: “, “”)- ^, @7 B; C* |: k
  ; Just in case – remove all carriage returns (`r)8 g1 m, B# Q& N0 I2 S
  StringReplace, full_path, full_path, `r, , all( w7 d8 N. D& `
  IfInString full_path, \8 g  U) X0 o% z: X1 Q4 G
  {& N! Z% ^; H! }
  Run, cmd /K cd /D “%full_path%”
' {9 {3 _; F! ^& ~- \5 q3 K& g  }
* Z: Q2 c& `# L- r0 x+ F' z$ Y9 R  else. ^1 z1 a& @" ~$ T$ e- ?+ o
  {/ |4 M2 t; K" X
  Run, cmd /K cd /D “C:\ ”: y- o0 P! S( e( q9 w# o
  }$ r  R+ W$ G" _+ l  ]# w
  }
% o# |, ]7 k$ y9 E6 F9 x  D' r9 j  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! g# [4 S1 Q$ G, p+ u, x: T
  这段小代码肯能有两个你需要修改的地方
' m2 f% j' d% g6 T) B" @; }, M  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 i& W* U" y% w' N/ M3 `% l8 E$ W
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “% Z% S7 p0 w# Q6 _
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-10-28 17:08 , Processed in 0.056043 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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