电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' O0 q% c$ t# [
  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。; Q& v. }& E% Y8 Q+ f6 ^" k
  方式一:. d+ x7 v' t% B
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 A7 x3 b* y$ ~0 |7 H; K# ~  D3 q( a
  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 C( {: c4 E+ a- w, G  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 @2 B1 H4 N) u- W/ Z/ Y: Y+ W! M  方式二:
# r/ R" I2 U) d4 U% _  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
  V* v) L3 f5 H4 E/ X  o  SetTitleMatchMode RegEx
. Y% G9 g! k* U) P# j2 I  return
$ J' ]+ A  v1 I& l+ l4 e# A$ {5 Y  ; Stuff to do when Windows Explorer is open
1 j$ |! W% T; D4 E) R  ;  t4 I7 S- O/ B* m, i
  #IfWinActive ahk_class ExploreWClass|CabinetWClass
* i1 j3 n" `4 c  ; open ‘cmd’ in the current directory4 z- ?$ A1 t1 D: S( c
  ;: L* u) e& L+ }- f# {; e8 P! r
  #c::) J+ T' ?+ e" w: @0 r% o
  OpenCmdInCurrent(): t3 N+ t; t4 R( L0 e: Y2 x- r
  return
4 j9 O4 Q) ~' _8 L8 u( G  #IfWinActive  W8 K9 s0 a& }- `" `4 L( U
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 T2 H9 F2 C7 J5 n
  ; Note: expecting to be run when the active window is Explorer.) C, N3 `; D. @8 ^* a
  ;* ?; P0 ?3 [$ ?  q! s
  OpenCmdInCurrent()
" l3 V' D2 f' e1 [( _" l  {9 {4 |$ `! N, @3 S
  ; This is required to get the full path of the file from the address bar
' O6 x9 ~& a: X  WinGetText, full_path, A
/ Z; m+ W; ~6 u: Y6 S  ; Split on newline (`n)
& C0 l7 G, b1 Y. f- _- H  StringSplit, word_array, full_path, `n" r! \) r- Y! X/ }5 l
  ; Take the first element from the array
7 L6 A; n. y3 t' E' v! l2 J  full_path = %word_array1%; |4 q% S3 L- T$ r! W
  ; strip to bare address/ t- V2 h) @" r9 T) ^
  full_path := RegExReplace(full_path, “地址: “, “”)
( s- h+ k% s0 E% q% M( v! R+ G- x  ; Just in case – remove all carriage returns (`r)3 B+ T3 ~3 L  u5 g+ X$ ]3 _; |& z
  StringReplace, full_path, full_path, `r, , all/ s6 z' T7 G' s( X$ w" B
  IfInString full_path, \8 m" S6 Q1 D. i; N) l" k
  {
4 K( `2 n5 h1 A( C$ b6 R3 J- o  Run, cmd /K cd /D “%full_path%”
- x( y0 m# Z3 q4 [% v! |  }' c' u& d4 e4 ]' e- _+ o9 R1 }
  else3 g! a* G( F' Y5 u& D
  {
# i$ N& T' R1 w, k, w  Run, cmd /K cd /D “C:\ ”+ f/ Z0 F7 ]# Q2 u
  }
* w+ d$ v: d3 o6 t- d  K) ]1 @# o  }
: B0 j, e- I; u$ S9 ?4 g# Y  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 @2 X& _. p  ?) ?1 l* h  这段小代码肯能有两个你需要修改的地方9 Q! h# l+ p5 S0 D( }; {
  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 e$ B. o2 p% j# @! L2 W" }  p9 E
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. ?& e& J. k0 H
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-3-28 02:53 , Processed in 0.057259 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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