电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 _5 V% c8 `2 u9 f% A
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 L9 |6 B& ]6 B* t- M  方式一:
( ]$ F' I* _* \, Y  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 g2 r7 c5 C) H' I9 \
  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 G; }/ I! A; k! f6 K
  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* A% ]/ n# U' J1 o# t, t
  方式二:2 s1 H. e+ B: k7 [# U
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:) a7 D, Y( e1 D: V0 X' }
  SetTitleMatchMode RegEx. ?! K9 |; _7 h5 a( {
  return$ B) K# n( g: ~5 Q6 k9 e$ o
  ; Stuff to do when Windows Explorer is open9 C" m+ }/ L! Q# f# {: k
  ;# j' z' c# I, r; O# F1 @
  #IfWinActive ahk_class ExploreWClass|CabinetWClass
! M! t2 g* a# S8 U3 C9 @6 ~. H  ; open ‘cmd’ in the current directory
1 W* Y$ |: P# i, M5 ]  ;
0 q$ o" r  w  c0 a9 {; M+ Y7 f  #c::
/ i3 W; z8 H& T) T5 w  OpenCmdInCurrent()
7 I0 W7 t3 q  i1 e  return
1 j. i2 w9 x+ u  R( I  #IfWinActive: n: a& h& s7 s5 f! v! B8 y, E
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 c# L1 G! w$ I4 x: d
  ; Note: expecting to be run when the active window is Explorer.. z9 R2 ^; v5 D0 T5 Z' w1 h
  ;  l7 Q  m' R+ C& a& q" A& ^. }
  OpenCmdInCurrent()5 Y/ j- ?$ [0 p: c( s# S; t* p
  {
4 A; j6 d; A) }5 p  ; This is required to get the full path of the file from the address bar
7 a( H! T* g/ D' y  WinGetText, full_path, A; z. E6 q0 g0 h  |' ~
  ; Split on newline (`n)
; r/ L6 e: ^3 o, {) ^8 `1 v  StringSplit, word_array, full_path, `n5 H7 t2 B) d0 b  v
  ; Take the first element from the array
! A, X& a2 z3 s, o  P$ h  full_path = %word_array1%
* x5 d2 O3 m7 |, j2 y9 R4 A* t3 a  ; strip to bare address
8 U+ h7 X" `! {: {' F2 m1 L  full_path := RegExReplace(full_path, “地址: “, “”)
: ?/ B  {% C2 s7 J  ; Just in case – remove all carriage returns (`r)% R6 b3 w, y, r  Q4 J  {3 \$ U
  StringReplace, full_path, full_path, `r, , all8 D5 h! y9 \* G* x; s7 T; G
  IfInString full_path, \
7 @- z. `( p8 L0 r  {
/ F: ?0 k; S! u( q- L. ?- y/ k6 W  Run, cmd /K cd /D “%full_path%”
1 `0 _2 Z- H" J& a- H: M0 \  }" m' \: `9 u) o0 h2 n5 n
  else
0 U4 U" d0 J4 V6 c) v; A& }  {; b% I5 y( j- j# T. c" i
  Run, cmd /K cd /D “C:\ ”
1 Z8 |9 q) ?: x4 B5 }# M  }/ L  h( K3 T  G" b, F+ r
  }
; q1 }3 g* E, H# w' L0 J- y! d, m  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- u- `% P, @8 l; ?: n# v* t  这段小代码肯能有两个你需要修改的地方
9 S. d1 c  ^. f3 @7 w1 g" n- t  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 o# L- V/ Z- g6 x  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
% Z# k% j  Y; c5 q& G
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-1-31 14:44 , Processed in 0.084143 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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