电脑互动吧

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

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

[复制链接]
发表于 2014-5-21 10:20:02 | 显示全部楼层 |阅读模式
  此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; h1 k7 j+ N7 W5 q. {  正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。+ U9 ]: y7 W  ?! J
  方式一:  Q( Z& J; W& G9 y$ X4 E
  在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: O$ \- r3 b$ J% A% G4 g3 ]  去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- c! r- C6 L4 s+ s  HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
# f- T9 R: m" [/ D$ U! n4 ?  方式二:' X8 b" L. h1 m& `( }3 S! p
  用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 x; \/ K  H% c9 @
  SetTitleMatchMode RegEx
( |7 w% a" X" |  return
7 Q( `  \) O0 ?  ; Stuff to do when Windows Explorer is open* r( Q. Y6 T$ }  Z' n( `+ _, Z
  ;/ U" |/ N% O  u8 ~
  #IfWinActive ahk_class ExploreWClass|CabinetWClass" L3 V; z6 m5 {: K' h+ k
  ; open ‘cmd’ in the current directory2 Y& ]8 R: S! B: R: b) O  X
  ;
3 _5 O# d1 q" @1 b  #c::' ?  t) v6 m6 a
  OpenCmdInCurrent()
3 o, x$ ]' @6 h8 r; L# E  return/ t2 S1 f1 X' x5 h$ f
  #IfWinActive, V3 L/ g* ~# {: C
  ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.4 `' Z8 E: R: D! Y
  ; Note: expecting to be run when the active window is Explorer.
2 d# z0 c( v- H5 k' s  ;
. t0 Z+ c7 p, J5 S% }4 @* }  OpenCmdInCurrent()
7 U7 f* \9 ?8 i5 V% l( ?  {
2 [0 h" {# j* E  F# k  ; This is required to get the full path of the file from the address bar
4 b+ ~, T" |' \7 J! _4 U  WinGetText, full_path, A
3 p8 Z" L9 {5 q0 ?8 b' _: O% M  ; Split on newline (`n)# b" g$ c( G5 I7 P8 n
  StringSplit, word_array, full_path, `n
/ W( n2 a5 Q* ]9 Z6 i# z  ; Take the first element from the array
/ N1 L! v# T1 T7 k  z' W$ s  full_path = %word_array1%
. J1 h2 y6 V5 |( P, ~* [  ; strip to bare address
% N, w# I, [+ J/ C0 y1 ^  full_path := RegExReplace(full_path, “地址: “, “”)
3 j8 h6 U( R2 i* j  ; Just in case – remove all carriage returns (`r)
) h) N6 i# @$ _5 y" h  StringReplace, full_path, full_path, `r, , all2 R4 u$ b4 F  O6 {3 C1 P
  IfInString full_path, \9 {' }* B+ B' ?9 N2 v$ Y) L
  {
6 d) f' I& @* M6 s  Run, cmd /K cd /D “%full_path%”! w: _8 s. }- R2 Q! W
  }
) c# S& t+ q# P) ~% q) P/ [  else
. Y9 c3 c; H! t* l, Q  {$ Y% H! _6 A0 e9 ?& Z9 @
  Run, cmd /K cd /D “C:\ ”
) a+ }) `9 C/ z  V$ Z. [8 I- Y% O& ~  }
( r+ ^; D' m# L5 p" P  }5 e  S7 d$ j# C* n/ e
  把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 a& q) K$ i# N" U$ n" u8 h
  这段小代码肯能有两个你需要修改的地方
4 I: I  C% s0 D) U7 y  1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# D+ V6 ]  {& s$ l& G6 j3 x
  2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: J: `5 F; U0 Q( s+ b( k( {
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2026-9-14 09:50 , Processed in 0.151801 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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