电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; H0 w4 d" X/ U8 _
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
5 _4 q& S/ [( ~9 \  F3 L  方式一:* t' l3 `) Z5 t
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
9 D1 s5 b% R. }  u  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" h; s; H- l. l' E; o; W! E; J6 Z7 o  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' D5 ^. a. M$ X8 @  方式二:+ R7 N# n& Z: d% w
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. r& o) _* f, @
  SetTitleMatchMode RegEx
% U: w$ K' T6 _  return
( A& t, c2 |' i! \' p% r7 \& k  ; Stuff to do when Windows Explorer is open! r. f- h3 ]  ?
  ;; L# j2 `5 y& H% v  N& l% R& ^$ f
  #IfWinActive ahk_class ExploreWClass|CabinetWClass/ t5 }# o% y7 \% L! j& W
  ; open ‘cmd’ in the current directory4 K! e+ ?9 H6 \# {, V! n
  ;2 N+ x+ J0 C7 q+ e0 _3 J
  #c::) {5 }$ ]* k0 M/ s6 U
  OpenCmdInCurrent()- k# D( j) @  f' n% @
  return( U- ^# t3 v  f( X
  #IfWinActive& l! P. e+ S- j& f  D! O, m& t
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 `" q: o; U* B* O7 Y: @: k( F
  ; Note: expecting to be run when the active window is Explorer.$ `/ {, h- X# U3 ^2 c
  ;
  a* f, S8 Z/ V3 J4 f8 ]! C7 C9 m  OpenCmdInCurrent()
" V, i, Z, X6 G8 L( K3 c, s  {' B: v2 b+ ?7 k6 U2 z( D& Q9 {* |
  ; This is required to get the full path of the file from the address bar& f9 Y# R$ A1 n
  WinGetText, full_path, A5 o/ {, l* J4 Y, _0 e5 |
  ; Split on newline (`n)8 {+ O1 F0 d7 h( [) t8 J9 }
  StringSplit, word_array, full_path, `n5 b/ F8 B! k1 F( o! z
  ; Take the first element from the array
2 _* u% ]! W, ?5 U- o5 u  Z  full_path = %word_array1%
/ n6 b& x  `, v& a5 U4 J9 w8 D  ; strip to bare address
3 ?' G4 ^0 K5 h5 c  full_path := RegExReplace(full_path, “地址: “, “”)
& t6 j8 t( H3 R* f% u  ; Just in case – remove all carriage returns (`r)
8 m# w" q1 t6 K0 r  I7 i2 p  StringReplace, full_path, full_path, `r, , all6 M4 U/ n- F4 b
  IfInString full_path, \3 S6 m9 P" }5 Y7 j
  {! t) S0 R; F8 Q# m" g+ A0 K
  Run, cmd /K cd /D “%full_path%”
" H4 T& S! t* o5 B: @4 }  }; P$ S4 [0 J" f
  else0 ?9 [( ^# I, |1 y# ]
  {
1 J$ X' \0 R6 m8 R2 I% {3 v  Run, cmd /K cd /D “C:\ ”3 q, \- j4 u2 _  e- t
  }4 L1 g/ ~5 [; j. E1 S6 b+ A3 f5 z
  }+ K( ]' ?, J9 l: ]
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 ^5 n% P6 R5 `% ^5 j
  这段小代码肯能有两个你需要修改的地方
! G  o9 B9 u4 a5 R! t3 m) F( {  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 [& Z% ^; W/ A$ f
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 l1 q$ V, [! s
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-11-9 02:04 , Processed in 0.085121 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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