此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% `) q5 s- T, O3 a, G: {* U5 E8 M 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 o8 ?- g6 W" h9 ~* c( t8 k
方式一:6 Z r% l0 X. c6 E# m
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: V; N& m. F& A' f) ], y 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
+ g& z* `: v- X5 s3 ]+ O9 j HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, |( Q$ a" w l1 p: `6 U" h2 i8 \: J
方式二:
4 u( M* j, w( W8 E/ } ^( x 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 u+ W: e+ U j w
SetTitleMatchMode RegEx
1 d0 V4 L+ ]8 z6 z S' z return
& g; q9 x ]" w ; Stuff to do when Windows Explorer is open0 T% t! x: `$ w7 X
;3 Z8 Y, J" {" T" @+ \+ ?7 _; S
#IfWinActive ahk_class ExploreWClass|CabinetWClass
4 j2 f* A8 k! I- S" S ; open ‘cmd’ in the current directory* I& `3 `6 t9 O, U) q5 ~ @
;+ _5 R3 j8 i$ S+ _
#c::
) M% I: S B+ t5 Z OpenCmdInCurrent()
# W+ h$ P; O+ Y4 g U4 K# T return
. r/ F9 F ~ n! _& A1 w #IfWinActive7 c2 Q2 g( e w [0 a( l" }
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% B# L9 l% m9 P4 Z4 c+ y1 h ; Note: expecting to be run when the active window is Explorer.9 P& ?9 D4 x( e+ H2 `6 ~
;4 A5 S- o5 w5 v) N& ^; [
OpenCmdInCurrent()$ ]: H( g$ p# C6 T* f4 {. C$ F
{) H- O! |0 } o+ V$ Z8 }2 M' G
; This is required to get the full path of the file from the address bar
- S ?" |, N& }/ o5 H' }! o1 x$ z WinGetText, full_path, A9 `8 Q- J, M) Y. i+ U
; Split on newline (`n)
2 A5 D) T# [# m4 C StringSplit, word_array, full_path, `n
0 h$ N3 @6 c* ]$ H4 q+ Z, I5 \ ; Take the first element from the array+ E4 \8 e9 h* I9 Y8 {9 S% ]! P; \
full_path = %word_array1%7 K, B) m) T3 {+ v% H
; strip to bare address
0 @7 i$ \( ]1 v full_path := RegExReplace(full_path, “地址: “, “”)
1 r+ s1 b+ ^7 Q) ] ; Just in case – remove all carriage returns (`r)
: C/ x% J% W, E$ i2 z StringReplace, full_path, full_path, `r, , all8 Y) m$ q5 |& [, i) h9 O# o
IfInString full_path, \$ F. J$ R* T4 k
{
% g# m) M7 X: D" ` Run, cmd /K cd /D “%full_path%”( Q9 ?* [4 w9 \( C, q' p' }
}
; {- N* C5 \5 j9 U% N& t! z/ f else- G9 D8 e$ M% r2 _- r: v4 U
{
4 c$ N. h5 M8 f# B S. Q Run, cmd /K cd /D “C:\ ”* C! C! h5 _9 Y. S
}
* M$ ^% @5 L& Z# `, b }& V. y7 d+ C7 i) X2 X! k6 X
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 @4 s d5 r0 V
这段小代码肯能有两个你需要修改的地方& F: x& }9 w+ v) @( ]
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
: ]+ r3 `- P% v) a' i5 H, D 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 D4 e( F9 e( f$ R8 C# _: Q
|