电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& p& A8 t1 a4 ^" z3 m4 q3 `  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ u) [3 p) d. l* i/ n1 Y
  方式一:
1 e8 Q$ N* W4 _% W8 H0 y  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 u: m2 K7 W( H# \
  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: S- d  }' m! _- W
  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ {$ n; g/ W0 W2 B* b+ r0 y  方式二:3 [- q: m1 S: j& X% p& h0 w1 g  U
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
3 g* i. g2 a. ?! |7 g( K" f& ^  SetTitleMatchMode RegEx
: u6 U' n6 Y5 X5 t8 X# P0 v0 m  return
/ H+ E. S# |8 F; G5 B4 o0 T  ; Stuff to do when Windows Explorer is open% L. u- K: Q) W/ H5 r% z) F
  ;3 L" W( @7 O# y: @9 F# {- C
  #IfWinActive ahk_class ExploreWClass|CabinetWClass
$ e0 l! G, A, A0 E  u' o  ; open ‘cmd’ in the current directory
! T: X, U2 \9 Q3 g  ;  ~9 E2 E* E; m/ E2 c5 n
  #c::
. y+ q7 ?/ {* |0 G" L7 V  OpenCmdInCurrent()2 T# I& p9 L0 c, O3 d- q. a" [
  return, V8 R, f& T4 k& Q% Z
  #IfWinActive
" e( t! h+ V( v0 g( B6 @  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
& u  @  Q% W9 o  ; Note: expecting to be run when the active window is Explorer.
2 r: Y- a8 |# Z1 w1 z6 Y+ G5 v( c  ;
8 G& I  z" `: j0 i( s  OpenCmdInCurrent()
' m( w' H( |6 W( U/ u' P6 M: g  {- S, ?7 ~) t5 Q- N, n
  ; This is required to get the full path of the file from the address bar
7 |  y0 ^: {( H" c8 B- o3 O1 S) u  WinGetText, full_path, A1 M, z" A6 `  T' w, v
  ; Split on newline (`n)5 V- P- \1 q7 l1 F  F% E
  StringSplit, word_array, full_path, `n5 L" P1 g+ [. y8 d
  ; Take the first element from the array( h9 c* d- t7 c* g& N2 D
  full_path = %word_array1%( d8 r$ _2 ^1 w  m8 v
  ; strip to bare address  S# x5 _" T* g+ S/ O
  full_path := RegExReplace(full_path, “地址: “, “”)
; @8 s4 f7 l& h7 V! H5 R  ; Just in case – remove all carriage returns (`r), s# F# i  A  k2 l
  StringReplace, full_path, full_path, `r, , all
  |- d) C2 {6 M  a  IfInString full_path, \7 }. ?2 K: L) V7 {" Z
  {3 |, R( B- x4 e% l7 u) `
  Run, cmd /K cd /D “%full_path%”) o0 y! g. u; j: j
  }
& i- b# g! p7 D  else
: y) X. P$ }& t) Q7 {1 b  {
. [5 O' z# {6 C- s' B  Run, cmd /K cd /D “C:\ ”) ?3 W& W. ]" c
  }2 M! W9 F4 {4 K9 y
  }/ y" K8 ^+ g, ?  t* C9 E
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
6 p  {  ~7 A4 {  这段小代码肯能有两个你需要修改的地方5 X, D: t! b. O
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ p. f+ g! L) s. b
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: i1 Y8 J0 M: C$ J6 G
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-5-11 18:03 , Processed in 0.065354 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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