电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
6 \/ E$ s9 I/ N$ {  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
/ _/ g7 r7 F0 v4 x) l7 O  方式一:% f5 _' B3 {" ~
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( K- b) A7 u+ n" f. b8 ^) I8 k) N
  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
# Z/ ~# E$ B' N6 d  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
: Q' a( T% o* \  方式二:- R$ k' s0 [2 h" {1 A. K6 ~
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
! b, `  ]+ p/ a  SetTitleMatchMode RegEx" l' i2 Y3 W% r6 g4 j: n3 G$ a, o; ]8 v
  return) o1 V8 B, R# r
  ; Stuff to do when Windows Explorer is open
5 {4 h  ~! W; V7 B: H( K  ;
! l  `2 V  b# }* p; @* W% q( g  #IfWinActive ahk_class ExploreWClass|CabinetWClass6 E  n- S" H( g1 t$ _" ?
  ; open ‘cmd’ in the current directory" H: {: z9 v$ Z8 j. e) y9 Y" _
  ;" B; O, u. L* t
  #c::5 }: n/ t4 d$ @% ?
  OpenCmdInCurrent(); }' l5 l6 G3 W" N! [
  return& w, P% e( z: Q/ \, e# S
  #IfWinActive$ k  `! ?$ x8 P8 Z" H4 ^, s% z: l
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: p; Q. R8 C2 L" K9 _5 O  ; Note: expecting to be run when the active window is Explorer.
, ^4 }1 v2 W4 r9 S) K9 {+ X  ;
  u' \3 ]8 _" v+ j- Y  OpenCmdInCurrent()2 l+ P( l2 V+ w) P' C( D
  {
: G& \- N( P) I/ m2 p7 [7 x  ; This is required to get the full path of the file from the address bar9 K; A  v4 {: {8 x' }+ z
  WinGetText, full_path, A
9 e6 d  J3 e8 J  ; Split on newline (`n)+ I: P) ~4 h! {# W8 P- x
  StringSplit, word_array, full_path, `n
$ m$ v2 y0 a1 h# V  ; Take the first element from the array- h' L8 k% ]5 L! C  D
  full_path = %word_array1%
/ E: O( x  X9 g  ; strip to bare address' q* e! E% F6 r) U# q  \
  full_path := RegExReplace(full_path, “地址: “, “”)0 s9 k1 ~' ~+ s( O# `  _
  ; Just in case – remove all carriage returns (`r)
$ N; Y( P3 Y5 y* V* U9 Y  StringReplace, full_path, full_path, `r, , all: ~6 {+ J/ ?1 Z1 i
  IfInString full_path, \
6 D& Z) c( @6 O  {% O; t$ k( B- y7 @5 Z' {3 T
  Run, cmd /K cd /D “%full_path%”4 F: ?% M  \. q% @+ g0 {; [
  }
, H' G9 n% l- d6 ~3 e  else; O  q: ~- k+ {" {2 _
  {  ^% g. i& t( d" T" D/ E
  Run, cmd /K cd /D “C:\ ”
- y: L+ \" x$ t; F! F0 t  }. T" E' z9 k1 e6 M4 T" [
  }
. _0 ^# t# Y4 `; O0 b0 e% m+ ~7 h  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ `: A" ^) y, U. N6 V2 f3 H
  这段小代码肯能有两个你需要修改的地方
6 S; V8 S, ~: @5 F  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
  K! l  x( Z5 Z) v: a  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “5 M' E( K. Q: o5 V' S. Q4 L
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-8-4 10:54 , Processed in 0.085004 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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