电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
* G; o6 Y7 \, I' ]+ {  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 F7 X9 G8 r2 m# X7 p  方式一:# N' L4 K7 W5 \. U! {
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ d) O" J" t3 P: H9 h: i0 |
  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" P; I/ d0 Z( M: j/ A  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) {$ p" q0 ~/ _" x7 A9 ?  方式二:5 W* H8 U  h" F2 d
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 M, C* p# x" o2 R- S* \! K" @# X
  SetTitleMatchMode RegEx3 o7 G' _2 M# J- d
  return* z# c6 q+ I' n% p! q$ i/ V' W- w% R
  ; Stuff to do when Windows Explorer is open
7 `* [7 y+ I4 [  ;
! ^  Y6 K" o5 y  a+ ?% [  #IfWinActive ahk_class ExploreWClass|CabinetWClass
. M: N$ j0 F6 T1 H2 T, E! [  ; open ‘cmd’ in the current directory( y" b+ ~3 k2 F$ j1 n' }
  ;9 a& |4 n+ E* F* b' k# b7 x
  #c::
! u3 p& L8 q2 P& a% S5 a6 r  G  M  OpenCmdInCurrent()
9 r* e. \2 u$ c& d  return
6 R$ p- w/ n9 h$ c/ g- Q6 H  #IfWinActive* o0 O  v& n. J4 J$ O3 y
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 ?* N. z4 V: x, ~6 J& q
  ; Note: expecting to be run when the active window is Explorer.5 y5 C( S2 S, ]
  ;
6 b7 m6 |, L( f% \7 L  OpenCmdInCurrent(); R; P4 v  D" Y9 f/ T# E3 @( n
  {
' r1 w5 F5 P4 t6 @' I; a. E  ; This is required to get the full path of the file from the address bar
$ t' m5 A. r4 |. Q" y0 K2 A; |  WinGetText, full_path, A$ l* Q* C% A' X# m7 T4 w- t; \
  ; Split on newline (`n)
% `. H7 o, H7 G' C( v" G5 R- ^  StringSplit, word_array, full_path, `n
# f+ f# E/ S9 _& w8 k. l, Q  ; Take the first element from the array
0 K- Y* D7 l. N9 ?  full_path = %word_array1%
% P% R! h" x+ G! I' P6 v. l; B+ j: P  ; strip to bare address
1 u( [+ Z- \. I; A4 E  full_path := RegExReplace(full_path, “地址: “, “”). O& M( s& j" E6 q/ G3 V0 C8 N/ g
  ; Just in case – remove all carriage returns (`r)
) {: D: U% v+ c  StringReplace, full_path, full_path, `r, , all) _* A5 Y5 ~! \2 ^
  IfInString full_path, \
; z2 G# Q7 ]: a' S$ K1 o  {
5 J, V' V' Q# P6 _6 }& h  Run, cmd /K cd /D “%full_path%”
2 N; V4 G1 G/ T" S- Z2 ?5 M  }
8 |/ h; X! r' F+ U5 [0 |% h  else9 p6 J2 P3 r6 T1 F5 u1 O6 M3 z
  {* u; x  M( o# K& _; y8 t
  Run, cmd /K cd /D “C:\ ”
, D4 W" G& z4 A: q9 `  }9 h& x: j! }- H8 ~
  }: Q6 u, ^! Q' v3 X, x: B4 K8 ^
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. x1 W4 D& u! ^+ ]; [/ V  这段小代码肯能有两个你需要修改的地方, Y) ~7 l" A  M7 ]( `: a
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
  y# ~5 d# N* m+ Q5 h1 S  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ Y, f, G9 ?" B' G5 r
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-12-3 21:33 , Processed in 0.117207 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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