电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( l. a' P) I) i* \0 z
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
# D; e8 C6 @8 }3 N  方式一:( B! ~( {! i$ x8 q
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ r" r2 `9 ^4 v7 A+ F
  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和  B+ h6 q! V3 i, t9 p
  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" n7 E, i4 F4 o- J
  方式二:* s8 \4 j7 _8 k6 o* `
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
6 {3 T! ~: U9 T" B4 f* b! z+ S  SetTitleMatchMode RegEx3 @# t" ^+ M, E( W) t, G' j
  return
6 ~. n) s5 J+ u+ ]4 A+ \  ; Stuff to do when Windows Explorer is open
1 P$ b7 J8 l5 N& V0 f  ;5 q  R) Z7 |  ~5 w
  #IfWinActive ahk_class ExploreWClass|CabinetWClass
' `( m$ h5 g+ }5 ^+ r  ; open ‘cmd’ in the current directory
" Y( @, [6 g* d! C) f4 \+ K  ;
- K4 L6 j: U$ m& h# E8 W  #c::) J2 k2 d7 N0 R( r* S! }7 w
  OpenCmdInCurrent()+ v6 [6 l6 y  P3 u
  return5 t' B  x$ z6 w' I  ?3 j3 P" l
  #IfWinActive7 `6 s# ?5 K4 _& ^' n0 [. p: H
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 y/ w1 s6 N/ O/ T( S+ w
  ; Note: expecting to be run when the active window is Explorer.
" D, o1 z1 I# N3 @1 s' i) D5 p  ;* s6 z7 @$ |% ^  o  A- P' D
  OpenCmdInCurrent()7 C& Y" d. f  k: S3 ^  a
  {
/ _* D# Y/ }3 D( ~6 R  ; This is required to get the full path of the file from the address bar
2 R  j: _7 _  C  WinGetText, full_path, A
3 P. {4 u4 q# X6 t# J: M+ i/ b  ; Split on newline (`n)9 V3 f! [' n8 p. \6 C7 p
  StringSplit, word_array, full_path, `n2 M' q7 C4 M9 I* |
  ; Take the first element from the array
( H4 h1 O( r0 x0 C- \% [  C  full_path = %word_array1%
' ]. ~. y6 n1 a5 \  ; strip to bare address! V5 N3 U! e& }
  full_path := RegExReplace(full_path, “地址: “, “”)
4 p* s; T& E7 K+ {  ; Just in case – remove all carriage returns (`r)* A% K) ?* Q7 x8 @
  StringReplace, full_path, full_path, `r, , all
4 E% G3 ]) y; K1 S8 J& G1 P/ j$ B  IfInString full_path, \
! y, c/ u% F$ r1 o# h  {
8 w/ t, a. F+ B5 a* W+ Z; l  Run, cmd /K cd /D “%full_path%”
; V: }7 X0 d2 Y* Q  }% ^( W; s% z2 ~' X2 x
  else
0 }5 r/ M/ }! [# l& e: u" F  {
- j4 [' A5 k2 a3 {8 X2 m& o  Run, cmd /K cd /D “C:\ ”* a8 {, J9 c- B  j+ }) }% D
  }
- z) [* Z. H# ^2 q6 N. q  }
9 o7 g% V# C& l5 D0 {/ a  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# m6 B% N& z* t! Z  这段小代码肯能有两个你需要修改的地方
* J# [: b1 Y+ J- C/ j  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键1 o! U2 f$ @0 ^. ~( [+ R
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “' {) @( m4 y- h" t9 e% u  z
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-4-1 14:41 , Processed in 0.087514 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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