电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* }7 x1 G3 g: _
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ V$ ?% l7 s  b/ r5 {3 R. r
  方式一:' K, ?0 y' W; y. k; a4 t2 w! K/ C4 W
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 y- i  N, L, I  c5 s2 C  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 e, f0 j1 E( {( H  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
: U  ~7 Q3 U5 b  方式二:& H- w! X( e% r& a0 P& w  p
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
: T& y! s( ^, Q* R  SetTitleMatchMode RegEx
3 G7 a: o/ n, k% Y! h$ I3 Y  return
' l" F& f; A; p! r  ; Stuff to do when Windows Explorer is open" H! m6 ?* S* W  A) @0 _# l
  ;
- r8 y8 D" \8 V  #IfWinActive ahk_class ExploreWClass|CabinetWClass5 v6 V  ]6 P% Z
  ; open ‘cmd’ in the current directory
5 K5 P3 X/ A  }0 I/ O  z/ G  ;- W& O; [( V% Q' C
  #c::" E5 m4 |0 B+ p3 I0 m4 n( X2 {) o
  OpenCmdInCurrent(), d5 t' \: p3 E, y9 O0 x& w: e
  return
7 {6 W- e$ U; F6 Q8 e' R; u  #IfWinActive4 t( _6 ~0 _& F3 Y# b. o$ P2 G
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) |: N: o4 D3 C
  ; Note: expecting to be run when the active window is Explorer.
2 b( k/ z, K, z1 e- T  ;
0 `* N2 {4 Z5 E& l5 D0 l6 e  OpenCmdInCurrent()
, n3 B- u! k- a% d' q5 P1 L, m* b5 m  {
3 `3 }0 ~8 H  I! ~  ; This is required to get the full path of the file from the address bar
" D# p& d4 R6 D! `/ b) n2 J  WinGetText, full_path, A
0 n. e- z$ f0 p7 l2 ~1 m9 F  ; Split on newline (`n)" L/ j+ A6 B% M7 J" a( z
  StringSplit, word_array, full_path, `n2 g% ]+ Q1 ?, r8 @+ x. ^
  ; Take the first element from the array2 g# h! a+ ~* Y- `+ _
  full_path = %word_array1%6 p# W) A6 e& w+ d; R
  ; strip to bare address( F' n* O) j  O  G$ w! j; k; D5 {+ L6 a
  full_path := RegExReplace(full_path, “地址: “, “”)
) P" R& u2 \6 W7 `% P  ; Just in case – remove all carriage returns (`r)
7 Q# {7 p) D- d/ d- I/ s  StringReplace, full_path, full_path, `r, , all
$ }+ E; h7 T$ |2 c- e0 H* x  R  IfInString full_path, \  a2 o" Y$ v7 c, V0 d: R7 n
  {: [6 j5 f7 d8 Y1 |) p0 d$ r: k1 ?1 s
  Run, cmd /K cd /D “%full_path%”  j$ U$ s2 @/ P. ^$ s! S5 p  d
  }% |9 Q- |2 q/ @; C/ e
  else
  c% {! |' n- g) P3 Z: t  {
) B$ J3 o* O5 D7 |- H7 s  Run, cmd /K cd /D “C:\ ”: C5 J7 \+ [  k% Q. R
  }
9 M) m' t3 X8 m. [7 ]; C& ]1 }  }
& d  X* i9 j: @6 g  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。4 s4 t& S8 G$ C+ n% @
  这段小代码肯能有两个你需要修改的地方
' @0 L6 r4 G" J& e4 e% ]  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' Y+ |# {9 L3 L; \
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 Y! H- R, S. ~9 |9 M9 N2 f4 k
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-6-11 08:55 , Processed in 0.059180 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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