电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* M: S( {' {  ^$ T. d
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- u/ x; b6 O. S) S  方式一:: Y3 t6 a; L2 M) E+ ~
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 J  m7 N: e. t2 w  `) p$ A, z5 [
  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 I! m* X7 }8 B1 p  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* B3 l. T  }  d' _7 c  方式二:* |% a5 ]2 H( |
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 f, Y# ]1 [; D
  SetTitleMatchMode RegEx3 @+ r% p) J# W( Q
  return. _* \3 I3 X9 ?5 a; d
  ; Stuff to do when Windows Explorer is open
' ?5 R2 z; Z) \+ y  ;
% A2 [& C9 m% d+ N# d% f  #IfWinActive ahk_class ExploreWClass|CabinetWClass
) u! F+ ]0 C9 U0 g) Z' E  ; open ‘cmd’ in the current directory
& e2 F" M3 K+ I5 z+ @: M  ;
/ ?! G9 [% N: I; M% m' |/ ?+ I. ]* J  #c::
2 Y& k* x) J4 b# j9 @0 q8 y+ l7 l  OpenCmdInCurrent()7 K# @7 i( r" t) m" V( x! s6 H
  return
1 W) q6 Y) d8 }/ C  #IfWinActive( W5 K$ t* l, K/ o9 D* [
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* ^0 [( K; A/ m
  ; Note: expecting to be run when the active window is Explorer.! W; p1 e1 [1 e3 ?  `( d8 V! h
  ;
: M6 F2 r( b; b* e  OpenCmdInCurrent()  _: m  v% K0 D4 ?* j8 [9 }- D
  {
: w6 z: w: `6 B' f/ E  ; This is required to get the full path of the file from the address bar
& @$ d( u* P3 i2 u, r  WinGetText, full_path, A
/ c2 t7 y) }: d  ; Split on newline (`n)$ }2 }. \' q4 J: ]" m
  StringSplit, word_array, full_path, `n7 p9 K( U0 N, K, C8 ^; c7 V
  ; Take the first element from the array
& R" [* ?! g# Z# p  full_path = %word_array1%; L: {/ A1 d+ a( h4 R/ Q
  ; strip to bare address  m. z! _4 G# [2 `
  full_path := RegExReplace(full_path, “地址: “, “”). T9 r" E: c$ p) `9 e
  ; Just in case – remove all carriage returns (`r)
# H4 V& K$ O; ]7 g/ S5 C$ h+ @: c  StringReplace, full_path, full_path, `r, , all
  V- @1 F1 U/ b* ^+ u; w  IfInString full_path, \
# p! ~  Z9 |: a$ n: X  o  {% @" y% _6 c- Z; Q7 B
  Run, cmd /K cd /D “%full_path%”
$ K0 f$ M7 @7 ?$ k  }0 {4 v" Y. {  O. M% S
  else. z5 G$ L% L2 e' n0 l3 t- c! C7 \
  {. a" Z( I8 k  I8 s
  Run, cmd /K cd /D “C:\ ”
- t. Z: l7 _9 s# `  }
7 Q; x* N1 j) ]5 L, ?  }4 t# P' E9 M0 ^4 C5 F0 ?! O! j
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。. v+ }/ K) n4 J. ~# s7 w3 I0 M  Y4 y
  这段小代码肯能有两个你需要修改的地方& h4 h3 F' H  [4 N6 [
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键  e& W6 Y/ `/ ~( X( [
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( T2 ~2 X; k- L" [2 l- t8 N) _
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-3-11 14:40 , Processed in 0.097976 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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