电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) Y% Q# b( u% a6 _
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
. e: H' Z) [- i  方式一:( u) N9 ?" G+ }6 K9 T; }
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- p+ l) H( f  V; b' }6 j8 e2 ]6 Y7 k  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
% j8 z. y# N( ?/ k1 W  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! x6 e4 o: O1 }/ V  方式二:
- O( Z2 w: Q* n/ c* @. `& ]  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, b/ i/ ?3 q, y0 A% E9 Z# i. h, I! O
  SetTitleMatchMode RegEx  `5 ?. I) P; W! q
  return
2 Q3 g" h2 k6 {2 G6 j8 _3 ~  ; Stuff to do when Windows Explorer is open
! @$ c. l' `- l5 x# `) Q  ;
1 G8 t" c5 y' ~% c6 Z  #IfWinActive ahk_class ExploreWClass|CabinetWClass
8 b( Q/ e% `. T' h# L  ; open ‘cmd’ in the current directory
& B7 o3 ~4 J8 F7 D! d( D! S" x  ;/ C9 `! ]% a2 k+ p5 f3 z9 \& r& I. K" Z
  #c::
! Z4 i2 E( q/ E+ b7 I  OpenCmdInCurrent(), i9 X3 B8 P7 x+ F$ f+ P" n9 f' ]
  return# K6 S! S5 U4 l; [2 g
  #IfWinActive
6 D2 Y; T. v- V, m9 g  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( @: D! Q0 t( T
  ; Note: expecting to be run when the active window is Explorer.4 z7 X5 z# ~& d7 I
  ;. f" g# |1 }. \- k# H
  OpenCmdInCurrent()
; V9 ?, K1 U! D  {* }/ m1 K1 m6 @, {1 i
  ; This is required to get the full path of the file from the address bar
: K0 F; I4 g+ y0 `  WinGetText, full_path, A
+ `( R. [3 T- n* [! x  ; Split on newline (`n)
$ o% g" n; x1 S4 I  StringSplit, word_array, full_path, `n# L; J* E2 q; I# C4 Y* E
  ; Take the first element from the array
. e) v/ R/ A3 G9 Q" }  full_path = %word_array1%
# D% U& i$ K4 \/ |2 q  ; strip to bare address* a$ @5 W- g, Y; w3 a. W  R/ p
  full_path := RegExReplace(full_path, “地址: “, “”)
& [. g4 {8 `1 |6 ~& K  ; Just in case – remove all carriage returns (`r)  _8 I! H  @1 [$ p$ ?
  StringReplace, full_path, full_path, `r, , all
" k/ c" K* f, [$ T7 l  IfInString full_path, \
& O' ^  L2 U+ u6 Q5 ~  ]5 n  {; d5 S* _6 F9 ^6 ?. D7 u
  Run, cmd /K cd /D “%full_path%”
9 l2 a: W) r2 p6 V# I  }$ t9 i1 E8 d( k
  else  u) H; i' y. o2 e% j, l
  {
$ T! {* |3 Y, @2 R# ?  Run, cmd /K cd /D “C:\ ”2 P" X: T. F5 i
  }
  Y: J% K- G  K  }
: v$ ~& D, N+ _& `. V  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" S7 P9 B" ~6 q8 x3 k5 W- a7 R
  这段小代码肯能有两个你需要修改的地方, m* l# P" I3 ]. S+ [$ S0 L
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- J, u- |/ v/ K( p
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! E& f, w5 t" X: n3 Y6 Q# z+ q
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-6-7 04:35 , Processed in 0.099545 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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