电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- `: ~& X$ L2 x8 o' c  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& q' o" Y# b3 K3 _  方式一:
0 `- b0 F$ D3 Q' W6 x9 z' [6 W  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 C. _4 R% o9 M5 d2 [
  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 L$ _8 P/ k( {( h. {5 d1 u
  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 X. K" g* _- Y6 C
  方式二:
6 m) o2 O& A7 o# m  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# Z+ V9 U  |3 e: j  SetTitleMatchMode RegEx- J5 Z9 D1 D* g, i
  return
3 ^# ?2 X, z; C5 s4 l+ h  ; Stuff to do when Windows Explorer is open7 s% {# e2 d! y& b" z) R5 N9 T
  ;: o1 }# \/ P0 S
  #IfWinActive ahk_class ExploreWClass|CabinetWClass
; F+ n$ y. U& P' p) v) j4 `, w% c  ; open ‘cmd’ in the current directory9 p# h; {, h' M+ m/ `
  ;4 m& G5 j/ Z5 `
  #c::
9 X, C! {5 x1 ?( W+ P. D$ ]  OpenCmdInCurrent()
' T5 t4 P7 M  a+ C2 ^* x( m. n  return5 N- m# I; G9 R  m  p- G
  #IfWinActive/ i& R  b$ A& o% I. h& o
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
$ l2 k9 o! A4 [! O+ \  ; Note: expecting to be run when the active window is Explorer.
( X/ d8 M% v3 m: j* P& ^5 S  ;
7 J  a9 x0 U/ v- S+ q: \/ G3 W. B, B/ M  OpenCmdInCurrent()
8 q0 d5 e1 a: G% F4 _: r) }  {5 ~: d: [& i- o, U
  ; This is required to get the full path of the file from the address bar
' `4 Q/ M- [) A( u2 L( r% X  WinGetText, full_path, A8 c+ ?5 s0 l) }7 h
  ; Split on newline (`n)
# ?$ Z0 {1 O( L0 W* P  StringSplit, word_array, full_path, `n7 t; l- ~! s6 S4 J" P- W0 u3 o
  ; Take the first element from the array$ y& c5 [/ z8 q6 b
  full_path = %word_array1%
& k1 W" T) Z+ {4 i# V  ; strip to bare address
3 E6 ?5 f- _4 T- F  full_path := RegExReplace(full_path, “地址: “, “”)
- }) f8 V; y# \9 ~  ; Just in case – remove all carriage returns (`r)% P) u) I0 h' f8 j* |
  StringReplace, full_path, full_path, `r, , all; o) C/ ]: D* l' h) Z: \7 F8 p- A
  IfInString full_path, \
1 ]9 W5 f/ v( G; v3 |  {
# a2 V( D& `/ P( o) |/ B& @6 O; _( Q7 N  Run, cmd /K cd /D “%full_path%”5 i' N& _2 T: P; t  l8 b
  }4 M" n. e$ \+ q* Q
  else
6 f2 _' X8 |9 V$ F7 ~  {
- t9 E4 v" _8 g4 f% q  Run, cmd /K cd /D “C:\ ”
2 p6 d+ p6 D, |( }) h  }
  t# d; u9 d: L$ |& M! ?0 @  }
- t0 j6 @2 T" F  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
/ o) O& k: E- Y+ W3 z' {  这段小代码肯能有两个你需要修改的地方1 Z! k4 B: P- d* p1 o" H
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) i) ]% T* v: S: u! K; S: `; V7 J6 ?1 F
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 i6 I% c/ a6 d: u
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-12-3 14:52 , Processed in 0.053101 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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