电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
: f  o, {0 Y% E  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
5 m: X/ I- J6 L2 Y4 G  方式一:
3 u. ]9 A. Z. A- ?& h; P  x  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 @% y7 y$ `2 ]' }4 H3 I
  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
+ W9 M9 R. M& C' n$ z. A. F) C  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ p7 y# j+ Y" o; v; Q  方式二:) _& a/ ~3 s* z# {3 n/ _3 }0 n
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:8 S2 N. e+ ~* P/ A$ J5 C6 B
  SetTitleMatchMode RegEx+ b5 G1 ~. R3 \; c; u, N4 x
  return# T- c9 q$ [+ M" j& J
  ; Stuff to do when Windows Explorer is open+ k* s, J9 U3 y
  ;4 \9 G1 U2 b# s  Y, H
  #IfWinActive ahk_class ExploreWClass|CabinetWClass0 V8 K. j+ |/ t4 c# P
  ; open ‘cmd’ in the current directory
, [# B9 G: p7 K' M% s  ;
* a7 r9 D  |4 y$ t2 [- m8 V  #c::
+ b$ c4 m, T" y1 [# p$ Y' v  OpenCmdInCurrent()8 [' i. i) Z7 B
  return( u# |# C8 b$ J2 h3 L$ N* n
  #IfWinActive* l/ {9 c& {8 L4 I2 c
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
! o" G* K" I3 e  h- [  ; Note: expecting to be run when the active window is Explorer.
2 Z  T) [8 b  j* j! r& X$ _  ;/ E' s, d+ C7 j2 B; U8 u$ [
  OpenCmdInCurrent()
  \1 C" u( E0 z2 q" G: Y  {
& G( m1 r( d( O  ; This is required to get the full path of the file from the address bar
3 d# B$ {6 x7 p* ^  WinGetText, full_path, A
* ?& y! [# i( F' X6 E  ; Split on newline (`n)5 @4 E: y1 E& Q  C7 _9 n% n
  StringSplit, word_array, full_path, `n
- u9 N* }2 ~6 d- Q. [  ; Take the first element from the array4 F$ I0 g2 ~& c7 |
  full_path = %word_array1%0 a2 |; U9 C5 t8 H8 `
  ; strip to bare address
' \0 H, i. a, n, |  full_path := RegExReplace(full_path, “地址: “, “”)1 w+ j+ T9 v0 {! Q0 r' g
  ; Just in case – remove all carriage returns (`r)
; v- c, M9 z  D' w- q8 P( {  StringReplace, full_path, full_path, `r, , all
7 g* }( B2 I8 q# {9 n  IfInString full_path, \
/ S: x. a" {* ?' i; X' y9 D) y( [  {
) r8 n& s+ f) Q, V  Run, cmd /K cd /D “%full_path%”* V8 F8 b9 s. j' A# }
  }+ ^( E4 M) Z+ ~8 |6 e
  else& A: K  `* R; Q1 f
  {7 |0 a1 C2 [% `6 L+ O
  Run, cmd /K cd /D “C:\ ”
' w$ X: t6 j6 n( n# s; U  }9 j1 e2 [) z6 `% g
  }! _0 H1 ]4 j* s! o* n" G- w1 F& z
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* g) a: m/ M) H# D( C
  这段小代码肯能有两个你需要修改的地方, I$ f3 o+ d4 U( K& w+ e# K, ^
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ i! t: V( V1 \- i* n6 e8 V" w0 y  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
, R9 x( V/ j/ k0 f1 a
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-11-19 17:25 , Processed in 0.067184 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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