电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
  h$ q3 V5 F5 J+ Z5 n  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
  O3 u" G3 Q3 C& \. o' {) Z  方式一:
7 ~6 {' X/ m5 p" o5 k! B+ ?  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
  x- y& L+ Q) D( w3 u7 d  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 Z6 l$ G* c1 c3 c2 ?( V  ^( D
  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- |4 M, t; Y+ A
  方式二:. ?# q$ G8 r6 |( ]+ o
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* m" d& Y' A2 o" ~+ [  SetTitleMatchMode RegEx
8 m9 p  Y; d' F. V  @  return# V: d  N4 @% e- t' N1 B
  ; Stuff to do when Windows Explorer is open3 O" L2 L# c) o' k
  ;
* r  u2 o6 {- Y4 Y# J  #IfWinActive ahk_class ExploreWClass|CabinetWClass. h' Q  R% @( W5 X1 \9 z+ `% K
  ; open ‘cmd’ in the current directory
- `4 Y1 N7 i! C  ;6 h+ C: x$ Z/ R$ [( a1 s7 p5 C
  #c::" A+ G, x' b+ p) N0 k
  OpenCmdInCurrent()4 l. I9 v$ N- Z; ]5 j5 c, @
  return
6 @1 J! i1 S& v, z& K  #IfWinActive
$ s. G% L& J0 M9 C0 _  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* n4 r- V" p& o, r% f9 g
  ; Note: expecting to be run when the active window is Explorer.6 n6 R  Q' e0 Z! h& K, p2 P6 V
  ;
& m! ~2 h, D6 n+ ~  OpenCmdInCurrent()# r5 O+ _" i  W, x- E- D7 ]
  {5 ]0 O) W3 ?& F0 C" B
  ; This is required to get the full path of the file from the address bar
) l$ G4 |, @, g# q9 Z4 G0 g, _  WinGetText, full_path, A  a' C$ B. ?: |' A" d* L2 p
  ; Split on newline (`n)+ r7 l8 @6 c* |
  StringSplit, word_array, full_path, `n
1 U+ H; e7 @" m  I/ O% W/ t# ^5 `  ; Take the first element from the array6 Z. H7 L0 ?0 ~0 U5 a- T
  full_path = %word_array1%9 e  V3 q; L" D  Z% T: b
  ; strip to bare address" {- K8 I) U% ?' A+ x
  full_path := RegExReplace(full_path, “地址: “, “”)
9 T! v: r; H1 ?) K- a8 l1 {+ o  ; Just in case – remove all carriage returns (`r)$ Y0 w1 o, x8 ]8 w
  StringReplace, full_path, full_path, `r, , all
0 I1 j$ T3 q) W  IfInString full_path, \5 K5 S1 F- @4 K$ ?3 Y( i
  {2 D: S5 w8 h0 x3 d0 i
  Run, cmd /K cd /D “%full_path%”
1 [8 @3 j7 ]( |$ Y  }" f1 n$ Y$ U0 t! L7 @/ h- d
  else
6 V& H0 c/ q% z  {- x: }# Y% r7 f) T
  Run, cmd /K cd /D “C:\ ”  t, X( f; M/ r* s
  }" W2 @0 V$ J, y* W$ [( r
  }
! M7 n, w! m7 E  B: D' Z  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 v% x3 z2 W4 D* H) d
  这段小代码肯能有两个你需要修改的地方
3 ?4 A9 s8 u) [+ \  `- ?5 k  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. J) z9 I3 _8 T" w* t  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 o2 g& S; R5 @
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-4-19 16:33 , Processed in 0.055664 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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