电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。5 `! C0 Z2 {( ^- P
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 M3 B8 C1 k7 ]6 w7 t& k% p
  方式一:
1 W+ I& r: n" B% W  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
8 `8 J& l- e/ c! N2 Z  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 ~8 `8 Z8 s/ C$ X
  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 x* _- z1 `1 O/ g
  方式二:" {, ?/ a  M! M4 P* H# V2 d
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:' a8 {; N$ b' U1 W& Y* |
  SetTitleMatchMode RegEx  W3 D4 U7 {: j7 M- j4 F6 t  h! o
  return
0 k. r* f; {4 q, i! {0 u' ]& O  ; Stuff to do when Windows Explorer is open
6 U  |8 g, a/ Y  ;
; p& ~# }8 f8 M4 T2 ^! R  #IfWinActive ahk_class ExploreWClass|CabinetWClass
0 P& ^0 e  A4 M' V  ; open ‘cmd’ in the current directory9 h5 c) c' T& d
  ;2 |- V, H. U1 P0 [* ]: p9 [
  #c::5 O3 P  k- w. W: ]1 K% n
  OpenCmdInCurrent()" \) x8 |$ Y5 u, _$ \$ J
  return" G3 y# o: f% G( l7 q7 [
  #IfWinActive& U; r1 x* V  C# X
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.; {, I3 Z4 K$ J3 i
  ; Note: expecting to be run when the active window is Explorer.8 s: \% }, v2 K9 ^0 p5 w
  ;
1 T' b4 s) b1 K8 H  OpenCmdInCurrent()
  H5 m7 \: ~; y, _- e7 ^/ z  {; {% v7 T1 p0 u% [
  ; This is required to get the full path of the file from the address bar
+ g  `* u/ U. W+ l- g! b, i* M  WinGetText, full_path, A$ U" Y, E3 U2 r- T
  ; Split on newline (`n)
6 e9 A) G$ R! p  ?  StringSplit, word_array, full_path, `n- s( {* y) A, f  w
  ; Take the first element from the array* x$ Q+ I- `) W7 [7 ~& F
  full_path = %word_array1%, ?1 @4 P! ^" U' u4 s% H  X: ^
  ; strip to bare address
/ X4 n" r3 l# ~, V% o" `  full_path := RegExReplace(full_path, “地址: “, “”)
' D6 o( h0 t  |/ a* V# \7 ]* O  ; Just in case – remove all carriage returns (`r)
& Z4 U4 f. J# I* R# ~! j8 z: v3 H  StringReplace, full_path, full_path, `r, , all/ C; H0 \. Q( a' ]7 C+ J
  IfInString full_path, \4 M( b! X- }) G: ]. ]- [; _& j
  {
  o0 ~- Z8 d4 R- ^5 Y  Run, cmd /K cd /D “%full_path%”' B7 \, x& W4 |# G& A/ |" k
  }( Y* o8 O9 W& G; t% o6 g7 I
  else7 B0 I- _3 O& I- c- y
  {
. d1 o) y/ S9 S8 D/ W2 e: F/ r4 f  Run, cmd /K cd /D “C:\ ”% ~, e+ }! I+ l5 s5 G2 K$ f$ X
  }: f: i0 m  u+ M; ~! \
  }
' Z5 f! E! y2 y6 U  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。+ k6 V1 d) d& E, k
  这段小代码肯能有两个你需要修改的地方
" K6 v9 d7 H* E6 i# E  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- x$ h; W* P+ m) w
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 @# B6 f0 w+ J$ f
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-12-22 16:20 , Processed in 0.056255 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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