电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- y/ z+ X$ N9 u  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
  b6 ~! V! R  j& s5 d7 `  方式一:5 s: V- S  c/ h- \4 c3 f
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) a% c0 g4 {6 I$ X6 m+ X2 ]" d) [  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) d- L* G4 x/ u" N3 `& C  O  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 N; J, L* |& ^6 r, X. }% O) ^
  方式二:
& a; M0 G8 W8 f8 ?+ ^# g  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
5 n, `0 A" b3 k* Q/ u7 d8 x  SetTitleMatchMode RegEx" r4 e% g9 J1 _
  return
  ^; V8 H: _$ x4 g/ |  ~4 Q0 X" Y  ; Stuff to do when Windows Explorer is open# o1 [0 o' T4 g' c
  ;0 r; G% [2 t7 B7 L+ C. B
  #IfWinActive ahk_class ExploreWClass|CabinetWClass, G: O7 b: y: D" `& p1 b! S' m4 f
  ; open ‘cmd’ in the current directory
" v, D4 Z! Y; J  ;
/ Z. A# M# b0 A6 q# Q( _# c  #c::+ F3 b! U4 B4 G9 d% R2 n3 y. e
  OpenCmdInCurrent()7 @  ^7 m& L' [) \1 L/ Z, _
  return; w" `/ a4 _: ?1 f* n5 d0 E
  #IfWinActive, t$ t6 _( Z: \
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 o: e& d0 S8 d, U" E) q2 w  ; Note: expecting to be run when the active window is Explorer.% q' ~: Q! n! w- l. V9 ?
  ;
; P& {( O5 q1 S3 v7 f3 g; ?  OpenCmdInCurrent()3 Q6 u" f6 u6 d( Q2 `
  {
  n* U1 T4 d1 ~6 Y  ; This is required to get the full path of the file from the address bar( P* |/ V# H' z
  WinGetText, full_path, A/ J4 l. G0 Z# _9 W9 W8 u
  ; Split on newline (`n)3 w) P3 l# d! Q/ U2 L' F, A
  StringSplit, word_array, full_path, `n' u- q  I% q6 C% n
  ; Take the first element from the array0 E4 x  Q; `) ^5 Z' {5 [9 P
  full_path = %word_array1%
& W) n  g( z; u1 ?4 Q! Y  ; strip to bare address
, {2 ]8 R6 S& u% |2 [7 c3 Q) I  full_path := RegExReplace(full_path, “地址: “, “”)
. M, z0 O# S+ z8 Y* V  ; Just in case – remove all carriage returns (`r)
2 J9 Z. q$ M' E* L1 _  StringReplace, full_path, full_path, `r, , all3 p0 q( X4 \& m1 B- m
  IfInString full_path, \2 Y# g. Z: o( @9 [- g
  {! K/ A9 n2 {* |8 w
  Run, cmd /K cd /D “%full_path%”
5 R. f) H8 F8 o7 b  }
8 V) C  Z6 t9 P- g/ J1 T- {( q; b  else
9 |$ b2 E4 M( r! O3 ]+ n* t- c9 L  {6 Q- x# |5 h$ m
  Run, cmd /K cd /D “C:\ ”
8 {- w' c. J  S0 ~4 @' b6 E1 u  }
* P$ w' x! V$ d# p* H( J" Q8 j  }
4 Z2 m/ k; k# ]8 B0 l  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 }7 f* Y1 D: g) y( r( O0 O4 {+ ~4 m  这段小代码肯能有两个你需要修改的地方; \/ q8 [, S/ t* }1 D5 |+ K& v5 @+ I
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
7 {  s8 k) v9 U9 Y/ x7 q3 \  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 ^3 t5 l5 T+ A2 r0 c; {/ a/ ?
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-8-5 17:59 , Processed in 0.113607 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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