此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! k$ H) m! d. L9 |+ r
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% x) D; |9 p# [
方式一:
& ~4 \' ]! B3 W3 M 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ }7 b% _, h* X
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; N+ m c: R0 ?+ j0 H HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 Z5 ?) p: j" l# o$ ?; S& [
方式二:
0 v6 Q1 Q5 J! L7 X& U: V 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
5 G& z& h8 w1 [% X. j SetTitleMatchMode RegEx
0 H' P& i: a3 U B- b6 |0 s/ \ return6 V4 D& S& O* h a, r) H
; Stuff to do when Windows Explorer is open
+ b, z" {7 ^; d5 [' K" x0 @ ;! _2 N+ x" @7 [2 D0 q
#IfWinActive ahk_class ExploreWClass|CabinetWClass
1 z' q$ B, U3 X( _* e$ B6 g ; open ‘cmd’ in the current directory% C, \5 I- ]; `2 H4 h3 }0 T
;
k. U: W# r( ~' R+ _' P: X #c::
5 y/ N: s) G6 l8 g OpenCmdInCurrent()
7 R* R0 f1 p3 c- f2 y+ M8 O return
5 G$ d c& S0 x+ j, }. ]9 { #IfWinActive. [1 P9 }) t, H; @, f) D7 i, \
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
& [+ \$ X& d) f6 w ; Note: expecting to be run when the active window is Explorer.
6 \; ^# ^ @& Y/ @6 ~0 p ;, H- t# ]; |/ L/ Y- M5 O) a
OpenCmdInCurrent()& N9 c; [: ~' b# l a! z
{6 d3 \9 q" V, O& J" e
; This is required to get the full path of the file from the address bar& O% i3 s( h# f) w2 t3 J0 B& K
WinGetText, full_path, A
A0 Q# y/ j, ] g7 s3 k ; Split on newline (`n)" B# p/ |# r) h, c2 b# l
StringSplit, word_array, full_path, `n
( c' H' ]5 u5 a ; Take the first element from the array; p* {) `9 W: ~; l, }
full_path = %word_array1%
) x% F( d/ j! d, K3 L, P ; strip to bare address$ @2 z3 h$ P0 Q: c9 e
full_path := RegExReplace(full_path, “地址: “, “”)
6 \0 B! B% A# c' w" k ; Just in case – remove all carriage returns (`r)
* D: e' Z! v1 ?: A% H+ M; \ StringReplace, full_path, full_path, `r, , all1 O; J' @* x- h/ a. [
IfInString full_path, \4 }: `8 J. R( L+ q3 ~
{
( O4 i9 ^# ~6 g, ? Run, cmd /K cd /D “%full_path%”
4 U1 Z+ L% r/ P P5 L, C( @$ i$ t }
; N- [ T# W! k, S8 u" s else1 \& i# @. l# e( S
{
0 v0 E+ Y. y8 ` Run, cmd /K cd /D “C:\ ” c4 ~1 C/ V3 {9 }& q; i
}
q) M# S, i8 y5 h$ I8 G }- P0 i9 x) `* |( t" u
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 }; i. v& S9 k0 T! _, w
这段小代码肯能有两个你需要修改的地方
! M! f% f- X& E' m( ~7 L: q& @2 E 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& ?, c. }% `5 V8 m3 X
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# j6 C9 ~$ b: n7 s! `6 {# y9 p, E: ?
|