电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' Z3 x) d; S% F. d, g$ a
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ b& K& r) Z# l- n# v. J+ j
  方式一:
9 |5 [6 ]) m2 r" S: l  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* r" m% p) W/ {% e9 b0 A% ]2 R8 ~
  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
& y; M# n9 L, E  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ o/ I; R# |! b1 Z  方式二:- W1 o3 _2 L- e; i* p
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 g3 u# h9 \. d6 m; c8 p% l
  SetTitleMatchMode RegEx
6 J. N5 o* s' ]7 p9 ]; w  return) g3 Q& a7 t' q1 Z: g
  ; Stuff to do when Windows Explorer is open" [) f* X  L0 `
  ;
) ]! r& `  M9 ?7 j! {  #IfWinActive ahk_class ExploreWClass|CabinetWClass3 [( I1 }+ v) ?
  ; open ‘cmd’ in the current directory
6 C; f5 Y; R6 m6 u# E  ;
1 n$ X  C# Q5 A: N( I6 H  #c::$ _7 q8 M% U9 j, i; b
  OpenCmdInCurrent()  m5 t) c: e" e) w8 Y7 j
  return
: _& q& Z& U. l! m, z  #IfWinActive
! w# Q1 s4 U: P  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* P- E* x/ P  s3 J+ P( y7 f  ; Note: expecting to be run when the active window is Explorer.
( N, {, V% |5 t; N# [8 J  ;# Z" {) M6 _7 Z3 e2 [- f
  OpenCmdInCurrent()
, E( i- @4 r" f; Q" w  {
* L1 J, o8 ?) y6 ?3 X6 Z  ; This is required to get the full path of the file from the address bar- w% \4 c  o5 o* f, B- U
  WinGetText, full_path, A2 M0 H; ]. U$ ]; p- g; m
  ; Split on newline (`n)
# T- }. z7 o/ |2 z$ i; Q# g$ r  StringSplit, word_array, full_path, `n
% N; z0 n  }0 L# Y  ; Take the first element from the array4 z; ?: m4 G6 X6 P9 |8 q/ j* Z
  full_path = %word_array1%& x; h. e2 X8 `1 g+ s5 P# b, b
  ; strip to bare address! y/ j, H" [1 w- }: o
  full_path := RegExReplace(full_path, “地址: “, “”)
( q7 b) |8 s$ }# H9 U  ; Just in case – remove all carriage returns (`r)' Q* U6 s/ e0 A! i6 T
  StringReplace, full_path, full_path, `r, , all9 |! `4 K5 `; p! b
  IfInString full_path, \$ b; l; K8 b- `" \" Y. K6 b0 i( S
  {
$ G; r: u% ]* p  [9 S! I! F* x8 O  Run, cmd /K cd /D “%full_path%”5 z. |/ A0 r( F
  }
) }5 N1 t/ [% A+ q; M& _" K, B% i  else
2 S6 A/ e( j0 n/ N  {/ P, l! y" z2 ~
  Run, cmd /K cd /D “C:\ ”
4 b' L6 B4 `! b0 b2 ^! Z  }- I5 i* N1 C0 l. }( }# Y: B% |0 M& M
  }0 ?6 t+ Y3 |* }8 U  R0 j
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 d' G. F- t" s9 N" e9 o& A! s3 v1 M
  这段小代码肯能有两个你需要修改的地方/ L) f% w$ C. }2 W( r, c4 A5 O( D
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 Z9 o$ Z& \  _: }& {+ h1 N  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “& J$ n" M0 F4 ~2 s% T$ [
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-5-1 04:19 , Processed in 0.077454 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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