此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 { {, H" M7 `/ o& x3 e
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
+ P9 ]: S& }" e4 u. I- P 方式一:0 i# J* O" ^+ O, F9 ]- Q
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( O8 ?" \+ u0 x9 L
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 j. P5 ?4 t2 ]6 k2 @, ?4 w9 h HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。. Q5 q& g, ]/ N5 f# L( r& Y
方式二:) S. d" i/ B, e2 A a. h& [
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ C4 P8 i* z4 j+ r7 s7 Y& H SetTitleMatchMode RegEx) A# C8 q3 f% x: B# l
return% V0 f& I/ |3 r; d
; Stuff to do when Windows Explorer is open- j- @3 T& r8 W3 }6 f8 n1 d
;1 m7 v$ X; e/ y' k- {3 n9 r
#IfWinActive ahk_class ExploreWClass|CabinetWClass
. _: Y! R! z. R/ T6 [1 V ; open ‘cmd’ in the current directory( y- K" Z; S3 e
;
' Y6 L8 N V) Q #c::
/ f; J; a" j. [" T* ~1 u OpenCmdInCurrent()4 T( F( I! K3 P" O) d! F, Z' [
return; X- B6 V+ {. {& `. I
#IfWinActive: J2 W3 f3 |% k5 s0 D* `! D
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
_! Z1 @! d* U( H ; Note: expecting to be run when the active window is Explorer.
1 d2 d) a6 Q2 K- `7 b) Y4 i/ r! v9 F6 e ;2 V2 u, N) K3 c# m7 E6 a* A
OpenCmdInCurrent()
. u. v! o- @+ Z$ z {
/ Z+ G: l, H9 b9 U. @# c3 }; z% C$ e ; This is required to get the full path of the file from the address bar+ r y$ x2 a' V4 U. V$ P8 m/ X
WinGetText, full_path, A
+ b& S# o3 a4 [$ O5 c ; Split on newline (`n)# ?& f$ Y" Z0 j4 N/ B
StringSplit, word_array, full_path, `n# H; ~ _; F' A# v; V) G
; Take the first element from the array
& W1 P; i4 |6 J1 ]) B& _8 v0 w7 ? full_path = %word_array1%
; c1 I3 t: d( _& B* p ; strip to bare address H$ Y. K/ ?6 U2 f' u) N
full_path := RegExReplace(full_path, “地址: “, “”)1 I; p6 k- l# I
; Just in case – remove all carriage returns (`r)
@; M9 k2 Q4 Q7 R* i, b StringReplace, full_path, full_path, `r, , all
W! Q% R% z9 f: K, K IfInString full_path, \
; ~ D4 T( P# z4 r- p {+ v! E! m% H& p* [
Run, cmd /K cd /D “%full_path%”- e. V8 ~2 F" k; J
}
+ Q( J! x G+ U! f0 q else9 g" @2 j+ g; J) c# c2 v3 T# Z
{$ z& e1 \7 Y( a
Run, cmd /K cd /D “C:\ ”0 \6 ?, a( L* Y; V6 o- L
}
: \7 ^$ o4 H! U3 u0 \ }
8 N. J' N/ m$ u! N8 q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ A( x3 B" L! R$ R# b" C
这段小代码肯能有两个你需要修改的地方
; l$ f7 Y& O' H 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键8 ]$ Y7 ^( F6 x/ r Y
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “/ V) r4 I5 t( u9 x+ I1 q" C
|