此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。7 a+ ]. O3 G9 K; U4 b% s3 V& \
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 b" x$ [0 d. x2 E( w/ N, ^# ]; e 方式一:
% A% \, C$ F$ u' A! L. N0 D 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 H: T8 _+ z- @' ? 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
0 F- `7 U/ j! B/ @3 e HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 V* r5 ]4 f1 y( e2 B
方式二:
1 \/ ]) n$ _% ~- a& U+ Y 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# m! v7 E6 A% c# U SetTitleMatchMode RegEx. \' K# p! e7 g" P- _& A$ z
return3 w/ t1 U! J3 p& }% ?6 v6 ?
; Stuff to do when Windows Explorer is open
! [4 G2 @8 C9 G) a Q( m& U ;( s# i9 k0 Z$ M) O9 X
#IfWinActive ahk_class ExploreWClass|CabinetWClass
- R. N$ z8 P/ S2 o8 E! S, q ; open ‘cmd’ in the current directory2 e% j5 k- X3 c1 M3 ?% j) ?/ j
;: A q5 x' G/ v) {0 x
#c::
4 ^1 l% z; I/ `! d S OpenCmdInCurrent()
" A4 K; I- F* q% o return* N+ @7 c) K; I# t8 \& \& G
#IfWinActive
: E: e+ n D( s% { y ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 L' e5 c$ N+ `) \+ B
; Note: expecting to be run when the active window is Explorer.
# E5 M; K; D. h1 b7 Z3 Z1 ]0 B+ c; t ;# g: Y: m) U- c! |' n* L
OpenCmdInCurrent()
- |3 D5 F6 z: W3 R {' z& ]2 W; q' T7 U( z
; This is required to get the full path of the file from the address bar
0 }4 W* k! u& y* n; s! x3 }) V WinGetText, full_path, A1 C7 z# D! i# O( t4 U
; Split on newline (`n)" I/ d4 ]0 g" ~* ^( B
StringSplit, word_array, full_path, `n
: V1 g0 R3 Y4 j9 }% ` ; Take the first element from the array
* E' s8 f" p2 t f full_path = %word_array1% ~7 K) P7 o% p- `* ?
; strip to bare address
) z2 R( p; H: D \ full_path := RegExReplace(full_path, “地址: “, “”)
" `( h3 {" j1 D ; Just in case – remove all carriage returns (`r) G% @9 }; M4 @, M
StringReplace, full_path, full_path, `r, , all
& P N4 s) Y! e IfInString full_path, \, \! _" d/ t1 t* A8 W- G# Y
{& Q* j5 V+ n& |8 u
Run, cmd /K cd /D “%full_path%”5 w1 s( F, j- j7 ]% T9 N% x
}
0 a: ~: s* {1 j( P1 K! \* R else
: L- m2 E. n2 d2 U+ F {3 [1 W" ?/ E" u5 S/ X b. K+ {% n
Run, cmd /K cd /D “C:\ ”
% A/ u; \" @3 m# N. y% k U- f }
5 e4 s) l, A. r! e0 j- d" Y }
( [% N' h' p$ X4 G- x# [9 R 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。$ [" R) _1 o, X5 A9 G$ T
这段小代码肯能有两个你需要修改的地方
+ O5 X& M7 X" I* N 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键2 F2 C, H, k% K9 k) K
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# `! t0 u& e7 j( A; F
|