电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
1 w, e+ x: [0 g5 N# u: v5 h  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。' d6 z+ M7 a9 h9 y  j/ @* A
  方式一:, Y' S, O" x/ p' r
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" S6 `  b8 |2 s; f  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
+ C2 R' y& |# U; t% P1 w  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。  [/ n% {0 o# W: J# {" x$ c+ q
  方式二:
. C- E* e$ k# i2 [  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 X$ q# p9 |% ?- n. u) b, o( R
  SetTitleMatchMode RegEx7 k  `# V) d, N3 T
  return1 b2 M2 Z  w) L+ U% K  R# x
  ; Stuff to do when Windows Explorer is open
" F7 A- O9 V" ~# E$ n  ;1 |  e, G. t, L7 G, `: s
  #IfWinActive ahk_class ExploreWClass|CabinetWClass
# m- I; O6 V' N  ; open ‘cmd’ in the current directory
( K) R) h* `1 P* `# s  ;) r' h: ^9 `' ~2 n, o* }
  #c::
( B1 y" B. u2 a0 M  t' N6 M- a  OpenCmdInCurrent()
/ z1 e. Y* ~6 D" ]7 |  return3 _/ V( b" M. a  }+ y/ p; A& K" K: k
  #IfWinActive
! C5 {- V. ^6 n  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer." f# s; |9 O0 Y" C
  ; Note: expecting to be run when the active window is Explorer.4 y8 \5 x: x# G4 D) E0 \! w
  ;
& ]. J7 Z$ v* g3 e  OpenCmdInCurrent()2 q" n* T8 E% A# \( @% u
  {3 S6 ?2 g4 e: C; }7 h' w
  ; This is required to get the full path of the file from the address bar
* p0 K2 ?4 ^8 ?8 _0 k# ]  WinGetText, full_path, A  P4 S% s0 c* v2 x( h
  ; Split on newline (`n)
- @( ?# T" ~) l0 E& j. _  StringSplit, word_array, full_path, `n
# v6 s! S$ T5 f. m  ; Take the first element from the array% _8 q$ |" A0 I% t, a
  full_path = %word_array1%  Y( O' V* h6 i
  ; strip to bare address
) ^1 a! e3 ?/ J4 Z  full_path := RegExReplace(full_path, “地址: “, “”)
7 l) `1 l* {$ H  ; Just in case – remove all carriage returns (`r); I; I6 {6 a( b5 a, b
  StringReplace, full_path, full_path, `r, , all2 a- `2 x8 d$ E6 R0 w% N+ t- b
  IfInString full_path, \$ u; X0 k: Q5 a- N
  {1 [* R- b9 z5 `( B+ E
  Run, cmd /K cd /D “%full_path%”( ?% v0 n: ?4 i$ J. c: X' P) c& ]
  }' u* i- D1 K; i+ Z/ @
  else- j; N6 Q& n! k$ y/ c
  {
+ y7 w7 \; M8 M; C1 Z  G. F: V' N6 C  Run, cmd /K cd /D “C:\ ”
, E! R! R4 b0 U7 M# X( a# h  }' r; X& T( p' D, t4 O  N% Q
  }  D% ?+ [9 q. \% W6 _3 e# o* P
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 n& \* v- X& \" S1 x  这段小代码肯能有两个你需要修改的地方% D/ H& _' d% Y! f
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
7 V7 V- w1 S& c  ^$ c# q  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) ?0 q$ Y# A- q& a1 s2 [; ?" v: p3 t
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-12-11 04:46 , Processed in 0.114098 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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