电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 M0 o* n% P$ ~2 e6 V
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 ]0 L7 w+ `+ [/ I# `( {5 a* Q
  方式一:4 N% U3 e5 z: r" \5 c
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 n+ F" W& k+ x" A$ l$ a  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 w- h: n6 a' w  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& r! m4 o3 k$ @0 c6 v+ [3 j  方式二:
. }% n+ D5 B7 F  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:# [" h6 D/ w# r7 F4 e
  SetTitleMatchMode RegEx
! ^( ?6 j& m0 }  R2 Q4 B2 S  return
7 P) _" x" p0 q! X% ]  ; Stuff to do when Windows Explorer is open& G. O) z9 i1 t+ ^& \
  ;
+ h7 z7 F8 z; O, }3 Q  #IfWinActive ahk_class ExploreWClass|CabinetWClass. ?; u' n( e1 t) P
  ; open ‘cmd’ in the current directory( N1 I' x. ?0 N" `- R8 X# \
  ;
2 x3 C; M5 d$ i+ W" l. O, e. g0 x4 O  #c::
- s1 y8 y! \3 P  u  OpenCmdInCurrent()
8 v) d# n' Q. C8 j4 c) F  return. O4 y! t6 v# K
  #IfWinActive
, L8 g+ w' }! X: c- |% a, y7 }0 F2 X3 }* O  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* }, m6 `: X6 F5 _, b# _5 T0 ?* C
  ; Note: expecting to be run when the active window is Explorer.
" y$ P3 ]9 v6 A3 @" B* c) x* R& O2 h+ S  ;1 \  J9 w8 y7 I1 |: A* j; J3 h% @+ S7 W
  OpenCmdInCurrent()0 A* E, f: h  z& f& w; t! P( e7 r. o
  {
8 v: U( C4 C5 I: i  ; This is required to get the full path of the file from the address bar
2 m( b; f1 _7 [  WinGetText, full_path, A
( G8 U/ t: [2 U7 ?; C  ; Split on newline (`n)
9 K( J2 P9 q  H- n' h7 V  StringSplit, word_array, full_path, `n. {9 W5 T  ~; t8 ^5 U) n* C; C0 a
  ; Take the first element from the array% h& O( Z% C$ T9 ]4 J- d" B
  full_path = %word_array1%$ r9 N# H2 p: ]- J
  ; strip to bare address/ y. M: I1 {! i
  full_path := RegExReplace(full_path, “地址: “, “”)4 e( X  S  d8 u# q2 n
  ; Just in case – remove all carriage returns (`r)
; H: U; f: N: ]0 |) c; ?4 p  StringReplace, full_path, full_path, `r, , all! Q/ Q3 R1 b* ^. c! y$ j
  IfInString full_path, \
9 l( U( l& p3 D7 E3 n" ~  {) P6 M/ b5 C9 w3 b# ]
  Run, cmd /K cd /D “%full_path%”
! O- W: G5 Z3 Y$ u  }- I* Y4 ]" I% i' u8 u/ N
  else
. |+ z6 T* x( }5 r/ x  {
& E! Q9 y$ C# M, @  V/ k* s  Run, cmd /K cd /D “C:\ ”2 g$ [- H- _; V4 h  _" e  t( `
  }
! P, N* U& A, K! E1 J6 N  }; t# ?3 k" G! Z' t0 L) [
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。. L2 F7 F% I8 I2 F
  这段小代码肯能有两个你需要修改的地方
; h/ {6 F/ _" N  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% @* D( s, Q2 _  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) k7 R9 T/ o6 v1 W- y
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-8-3 09:44 , Processed in 0.152487 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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