电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
9 s9 O8 Z; W( ~* v% r  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% W. g  A0 F% b0 x8 }7 g" ^! R
  方式一:
6 B. E- l' s0 p0 M" I) t3 y  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" e: z8 i" P# Q- _( I: s  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
* I, }& ^' @2 s7 e  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
; F& ^7 T' c0 [4 D  Y  P5 _+ m" b  方式二:; F( G, ~% h5 Q, \# f
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 o! x( c& i0 q9 F  SetTitleMatchMode RegEx
! x3 @9 [) y$ }8 S% h% v  `  return" d' r) D! t3 K0 \/ ?1 D# g  }
  ; Stuff to do when Windows Explorer is open) p. I2 N6 ?# o0 S2 W
  ;
, Z- ~, D+ {7 ^3 Y1 e: ^1 L' {  #IfWinActive ahk_class ExploreWClass|CabinetWClass3 |$ j  Z+ y& F" {9 \
  ; open ‘cmd’ in the current directory( {1 [4 m* k6 [0 o
  ;- G$ P; H- d) ^5 H, V7 I
  #c::6 N/ J/ i8 Y& L3 T6 q- e9 [
  OpenCmdInCurrent()
& l% e* ?5 ~* h' f  return
, s* w; G" M4 g/ v3 [: E. D7 |  #IfWinActive# ~2 U( D! l7 I$ s: P% V9 X7 M
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 v; I* p- L0 o: E; ~
  ; Note: expecting to be run when the active window is Explorer.
1 q/ t/ f% |' M. P  ;/ J5 v( Y& W( o  G7 f8 @
  OpenCmdInCurrent()' E* l# y. v: I: l* g
  {
% \3 T: Q( U( v! p  ; This is required to get the full path of the file from the address bar
. x  V4 m+ O. b7 n0 }& b  WinGetText, full_path, A
4 t4 S: i1 b  p4 Y9 \  T" t, Q' |  ; Split on newline (`n)
/ v; J5 g4 r5 ?/ {. p$ Z  StringSplit, word_array, full_path, `n
  q) H) k6 T8 ^  ; Take the first element from the array2 K1 r0 c) {% \* m( i
  full_path = %word_array1%
6 j2 h  `9 s; \: [9 X  ; strip to bare address
- h3 k. F/ H2 a- D  full_path := RegExReplace(full_path, “地址: “, “”)4 i4 X; ~) V: d# G! i  \
  ; Just in case – remove all carriage returns (`r)
* B5 b  u) J5 g: n6 Q8 G  StringReplace, full_path, full_path, `r, , all/ f4 A3 J; t5 Y7 `, u) O" A
  IfInString full_path, \6 S( Q, O" [) \+ z2 n
  {
2 A* {# h5 Y4 j! r" [3 p  Run, cmd /K cd /D “%full_path%”
; ~/ h' j  V* ?4 ^  }9 ]3 U6 y( F5 J. [. J
  else
4 p- a& f* W. P8 ~5 I$ G  {3 W9 R8 K- P) X) F
  Run, cmd /K cd /D “C:\ ”1 F8 r: m1 N0 i; o9 w' O. i& b5 U  C
  }' d: j/ N& u! p9 [6 z
  }+ }  Q8 g& y. `" `4 Z7 M
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 i: R& f. x: t; N* g& z: D; i
  这段小代码肯能有两个你需要修改的地方2 k; J* W' s0 _7 C
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 n, G6 C  d9 B& e) X
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 p0 |9 ?3 ]1 O, m
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-11-6 10:47 , Processed in 0.185720 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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