此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* E1 k% m8 `) l3 F2 m
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! ? }; q/ e- S5 _' y2 X9 g
方式一:4 M0 Y, i4 h: e3 d1 ^8 Y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,3 _# Y1 O% M( {( }, j$ N" Y5 s
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
J# l2 s9 D* ~* ]5 b5 F HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。3 M; M( ~1 ]( V |: N
方式二:% S3 }, V- {' A/ Z" i' y* }$ Y- R5 q
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ P" D( _ T' w- t- i2 \0 u SetTitleMatchMode RegEx) X- k) b" R/ D
return) _: Q) L0 T$ S+ U% E% x E
; Stuff to do when Windows Explorer is open- E, u- i' |4 z6 ]& h2 W3 O1 x
;4 H" b; i' p; m0 l6 u
#IfWinActive ahk_class ExploreWClass|CabinetWClass
9 c5 X/ M6 |* w9 b& V ; open ‘cmd’ in the current directory* Z% v( W9 ~& M. U0 `
;
) t1 C: f) K/ o; K! X! t4 t' z #c:: b: t8 S( [$ a0 H( V( q w& Q) l
OpenCmdInCurrent(), f- l4 C$ a& x6 X
return- f. c' o8 n; o1 E5 ^: t" e! F8 O
#IfWinActive! N1 S! m) r/ s+ N
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# C, b6 E6 {1 V2 |! C: X
; Note: expecting to be run when the active window is Explorer.* f0 ?2 c# Y5 Y$ Y% Y! j
;
* Z- n9 h# B/ P: p OpenCmdInCurrent()+ X9 ?: P# e1 Q! C
{) i- X' _ v2 s7 [8 }
; This is required to get the full path of the file from the address bar" P9 g0 C& t- @" W X+ a
WinGetText, full_path, A4 ~, H- e! _! l% ]
; Split on newline (`n)' u0 f$ n1 H+ j& J$ ~' H+ c0 E# b
StringSplit, word_array, full_path, `n
2 v d% v$ R9 T8 C/ R& P7 e" } ; Take the first element from the array
' b/ g8 ^8 c7 ^3 a# ]5 j9 p full_path = %word_array1%) e4 `1 C2 L0 ^/ q9 l K) j
; strip to bare address6 q* P5 G$ P& G7 i
full_path := RegExReplace(full_path, “地址: “, “”)9 [2 r) a I& y
; Just in case – remove all carriage returns (`r)
9 r) O$ N+ }9 ]9 ^9 |- T: Q StringReplace, full_path, full_path, `r, , all0 ] Z+ E+ h2 r, D" N
IfInString full_path, \5 T- B0 E8 ~5 M4 e& `$ q
{
4 }5 A5 i- \' k' p7 e Run, cmd /K cd /D “%full_path%”
! [! T1 e, Y E, d. `) \7 [* C }
; R" h* M$ u8 X" N7 F3 ` else
0 M2 k, Y1 q) E {
" D6 b, ? a6 O5 s4 u- z Run, cmd /K cd /D “C:\ ”; z' B- c" i$ o
}
- ^/ K# `0 S# ]3 u4 N9 e }5 r) u' ]6 G% Y d+ U6 X# {
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。8 F! x) n9 a6 v1 s& `4 D7 J5 ^0 f
这段小代码肯能有两个你需要修改的地方
% i: b @& k8 A) E; ? 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. q- U: ~7 p- N- ?# x 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; T) F, o- U' ?! O. M
|