电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。- p& K! u. b& L* B5 S; x; d0 ]& \4 `
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 t( `0 `! c, `
  方式一:; f& n" n6 ^, e3 a6 f& e1 c, d) M
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# i$ l+ T& ]8 w6 W% ]; s  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 f  h3 e3 j8 W% W4 V8 [0 t
  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 C! S( q# h+ Y4 [8 I  方式二:! P9 G) \8 W9 y, r. p- U# P
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# s  o" X8 T/ ~, e- r2 e+ J  SetTitleMatchMode RegEx7 s! f( }- }  l+ W# k2 Z$ |, I; ~: ~0 t
  return
! |4 H" }7 m& h' w  ; Stuff to do when Windows Explorer is open: ?1 j$ `8 k4 v7 P  R' W
  ;. [9 U8 a& ~6 \% u4 q; A( _
  #IfWinActive ahk_class ExploreWClass|CabinetWClass8 h! p: K% d$ a& ]# ]
  ; open ‘cmd’ in the current directory
# @3 e6 u, [% Q" }  ;" J  S! e$ T6 u# i% z
  #c::
# O/ N0 q* e/ |! K; h- R2 G: n+ j  OpenCmdInCurrent()/ j  q4 [) Z6 F
  return
# @+ M9 \) F- k, s  #IfWinActive) i! X; c8 w* v% ~5 X0 ^* i* D( t
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 e& u5 Q0 o4 F+ S1 F# u2 g  ; Note: expecting to be run when the active window is Explorer.4 \0 p' L3 e( A4 _# h- h, \
  ;
8 q% s/ F+ t2 F6 x/ @7 V5 S$ \  OpenCmdInCurrent()
) ?/ Q: _/ N$ h" |' M7 ?  {
6 m: h( s/ |* N7 Z( H1 S# R$ Y7 _0 K  ; This is required to get the full path of the file from the address bar1 G9 X4 q5 {% t1 s3 ~
  WinGetText, full_path, A
, U' n1 [* A# C  Z0 P/ `7 a9 Y  ; Split on newline (`n)( L" G* x/ i/ n) v! p
  StringSplit, word_array, full_path, `n
" m6 a9 ]; s- e1 M' x7 A& z! Q  ; Take the first element from the array
0 @: w2 z) l- ~( D3 a  full_path = %word_array1%
4 N0 s1 r% \/ J  p4 h  ; strip to bare address
: t3 A3 X1 p: s8 D1 L8 m  full_path := RegExReplace(full_path, “地址: “, “”)
  Y; F9 D! C& D! r* u% |  ; Just in case – remove all carriage returns (`r); [; `" m; e9 @4 ]
  StringReplace, full_path, full_path, `r, , all7 q. n# l. c5 Q/ D
  IfInString full_path, \& R  u- u. y3 G) C. ~, u
  {8 B0 b" g1 C' ~) T5 e' W/ A
  Run, cmd /K cd /D “%full_path%”
" F* N& L$ w5 j4 h  }; N& g) d9 G8 n/ t9 m2 n8 V
  else: r$ `* S( q- Y# r* Z: c/ H. Q  ?
  {
3 D9 t5 T/ |4 G: l0 e7 ^- k: Q  \  Run, cmd /K cd /D “C:\ ”) ?* ~- m5 p# |; b4 e) W! J
  }
3 ?+ p* ^$ {  E: q  K2 S; k! S  }
7 n( f; M; L% H8 E* p  ~; S  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。  ?: l) E3 E& v8 D' ]8 ]# Y
  这段小代码肯能有两个你需要修改的地方
* v3 l. z: ?: p/ N5 F+ o  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键, h3 ]7 ^& e' g& o. J% ?
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ ?& R2 R( C0 x% T/ F
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-12-9 04:37 , Processed in 0.054983 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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