电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 K. }% T& ]% r# k/ G& C
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
! g0 f! Y; S! z( q' o, w  方式一:6 h2 j- z& Z9 t* H
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" i) ]0 [7 z2 ?' G( k) J3 N3 `  f  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* G6 B6 P4 J+ v
  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。% ?4 _  q4 |- x6 G5 O% ^# ]
  方式二:
0 C; R9 N5 ]2 P  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, R, f1 I- x  W' v/ v6 X
  SetTitleMatchMode RegEx
5 t, u. y5 D7 h. f! ~  return6 O3 F6 E- q6 q; |& J
  ; Stuff to do when Windows Explorer is open
1 `$ F" [0 k$ x  ;- e( [. R8 `0 N* Q: D
  #IfWinActive ahk_class ExploreWClass|CabinetWClass
. W, F( y* J5 c+ ?( C. ]  ; open ‘cmd’ in the current directory
/ I$ O  o) [8 N( e& y/ A2 \  ;
. q9 S1 P( s# i( w- R  #c::6 N" c, a$ J; ]/ H
  OpenCmdInCurrent()$ f+ S& d) _. U6 R  }
  return, b/ f) ?; ^- y. N( w5 }
  #IfWinActive
7 ]6 ?* s, |, B+ |  Z  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 A2 o9 }  ?; `, d; f  ; Note: expecting to be run when the active window is Explorer.+ M1 A) o" e0 _
  ;
6 Q+ [5 f# d. C$ ~  OpenCmdInCurrent()
: E1 _. ?! z' C6 Y  \' G3 u  {/ y& g: p6 }# a$ F
  ; This is required to get the full path of the file from the address bar
" [$ |& T! b7 ^% a+ \/ w  N0 c  WinGetText, full_path, A
$ N' z9 s: B! \% Q! u: ]1 A) e  ; Split on newline (`n)
+ q' g/ q7 L8 f7 [  StringSplit, word_array, full_path, `n
7 U8 w2 A4 a7 d. u8 k" _- T  ; Take the first element from the array( H: a2 z, g5 _' ~
  full_path = %word_array1%' O, c$ P1 ^5 U
  ; strip to bare address8 S# I) j/ K3 C
  full_path := RegExReplace(full_path, “地址: “, “”)
% l) O  O; x+ Y; E5 b  ; Just in case – remove all carriage returns (`r)
( R8 Z4 W6 w* l8 i  StringReplace, full_path, full_path, `r, , all
6 d1 W( C+ J! u% n  IfInString full_path, \
" Y: Y4 o3 D) g9 K  {  {5 [3 |- x' j- V5 z4 U
  Run, cmd /K cd /D “%full_path%”- A+ o) v7 t$ G4 z0 _+ Q* R& \- O, h
  }5 b& w! D; G: ~0 y8 G/ g( s) [
  else- f+ ?% r4 W- ^6 w0 {
  {
/ B' l% E- U1 u" v6 f  [  Run, cmd /K cd /D “C:\ ”
9 e0 F/ o2 k: M6 b: a' v" a  }: L. U& z$ @/ J" \! J6 b3 w- W
  }
8 n2 V; K9 l" E! w/ m  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& J1 M7 U8 R2 y% \2 G  这段小代码肯能有两个你需要修改的地方/ ~& O+ N% \+ d$ i5 m8 A7 V
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 x! O% A( c2 _( g7 a+ @  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ Y$ b# V1 s) W8 z* E
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-11-14 13:57 , Processed in 0.067496 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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