电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% V) |3 j# W& Q! L- l
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 C$ f/ X- W8 c2 U/ j% `
  方式一:- H7 [% _, ^8 c# `+ I' i- w
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# @) s& _2 d# ^+ C/ |2 W( n* O  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
3 R1 j. W( }, E- p9 k2 G& V  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ y; M+ `9 i1 Y4 {) j+ t' w3 |
  方式二:
2 f% y1 P' i3 i3 K- O7 ^( K' S  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! v2 \! B, k1 W6 u& K
  SetTitleMatchMode RegEx
" a% `1 V, }4 K9 D$ i/ z: o7 |  return
+ |7 U8 n  O* E9 _# r* X* D  ; Stuff to do when Windows Explorer is open, I; F7 ~1 r9 n; [1 g
  ;: E% V9 Q$ {# R. }! k
  #IfWinActive ahk_class ExploreWClass|CabinetWClass. T& y" L( d7 j  A6 _
  ; open ‘cmd’ in the current directory
9 U2 n  q8 ^$ {  ;
  C$ u; ~7 A) i9 \! N2 o, f  #c::
& R! d# a, q$ h) u  }4 s  OpenCmdInCurrent()
8 R" V1 A1 c% a/ \  return
, `. q; a& I; n  r  #IfWinActive
4 d2 S: V4 t5 L0 |/ }5 F/ P  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ ]' G4 U% Q9 C0 x- A5 ^; b
  ; Note: expecting to be run when the active window is Explorer.
, k1 h) _: ~0 z4 X6 U% A% P  ;
: ?8 B: W( l, }& R9 X2 v) J! r  OpenCmdInCurrent()
5 S7 f3 }2 N! {% c( [5 F: x2 I) {  {  n3 _) a  e6 k, a; w
  ; This is required to get the full path of the file from the address bar
1 a2 h8 g5 o( {: a/ M* }  WinGetText, full_path, A
5 Y9 @  D( p1 g  ; Split on newline (`n)
5 W5 \( r( V  V) C  StringSplit, word_array, full_path, `n
: I! R5 `! i2 }# x! \3 U  ; Take the first element from the array
& O- g0 s0 N& ]# g) P& `  full_path = %word_array1%3 ^, `6 m( z% ]6 k
  ; strip to bare address
$ H7 a- Y  o( v3 [, `  ^  full_path := RegExReplace(full_path, “地址: “, “”)
8 ~  h3 V' q! f2 s8 M) X/ ?  ; Just in case – remove all carriage returns (`r)
# u# [# A  a4 B+ O3 N9 ^  StringReplace, full_path, full_path, `r, , all+ A7 J/ `7 [9 l8 p# U& t! D
  IfInString full_path, \
" M0 c# e! k- F  c4 m6 ~8 O  {
* X# K/ s+ a7 ?$ y  }  Run, cmd /K cd /D “%full_path%”0 M5 g1 p+ ]. o
  }5 X7 M) }% I* I4 t% C
  else; O, S- L  y1 s- V. B4 s
  {2 v/ w  P& f* A$ N  f& x) }3 e6 d
  Run, cmd /K cd /D “C:\ ”
; E) w' [2 c, p' K2 ~  }
/ X1 Q; O0 `. H/ L  }
% c% G4 |  _0 z- u8 X  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% W) E/ X3 O$ B8 K7 K
  这段小代码肯能有两个你需要修改的地方
. f8 M3 V- w& q  p) ^8 h7 ^. J# m  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键" f4 C( B: A: K0 M7 ^1 i! ]
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ E1 E6 ^7 F5 |3 C8 _
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-4-4 21:43 , Processed in 0.067803 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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