此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 Q |, J8 J; y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
' l, b- x5 |! [! f 方式一:
* O" Z2 A3 F7 w1 t' O' B7 @ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
9 M0 b$ N/ F. W- E# [7 j 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" n* A( v0 P) g: U, x' F
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
: t% j0 O, I0 a1 C* J 方式二:
0 G3 N: g9 Z3 |1 D+ o% U 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: y. i& d; Q" ?2 z7 \
SetTitleMatchMode RegEx1 k! w9 }# A/ @1 \& r5 E+ `
return$ u& j+ j1 T: J3 s
; Stuff to do when Windows Explorer is open
& z" U ^1 j! n2 D9 a ;- G, ] m5 [3 L# c; n5 x1 A& B
#IfWinActive ahk_class ExploreWClass|CabinetWClass
& }. K& j9 s1 w5 x+ p3 S2 d ; open ‘cmd’ in the current directory( S1 l5 p6 u2 w- i: _ _
;$ [( H. C+ Q) K8 G& _
#c::
; d7 o6 S( Y6 s, G" t OpenCmdInCurrent()
* }* ^: p3 S) M+ O# d6 d; M return# s- E, v' I: ? s0 b. g; V% b
#IfWinActive
9 c! ]; j( k: r0 Q% [ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
0 r1 l. T3 l1 y! Q/ z+ v7 p4 { ; Note: expecting to be run when the active window is Explorer.$ J) d; Z; K, X/ d& O% {
;# V" W& N$ R1 o/ S' f
OpenCmdInCurrent()
/ s0 |, q) |$ j! |& _- g2 _ {
$ u, ^( U! e+ e ; This is required to get the full path of the file from the address bar5 u3 x5 ?+ Q* l6 n( @, R
WinGetText, full_path, A
, B8 n; Q7 Y, V ; Split on newline (`n)
; T) _# f- Z: M" {) E( W StringSplit, word_array, full_path, `n
7 V* r l8 s0 p, J+ e3 | ; Take the first element from the array7 z& w3 }7 z# B1 { r
full_path = %word_array1%7 ?# K' y7 C7 l& \5 Y i! n3 U$ J! Y% z
; strip to bare address
' g8 ~0 [7 s5 `1 C" `9 G% O full_path := RegExReplace(full_path, “地址: “, “”)
" }1 N* u5 Q( p# o+ u, L ; Just in case – remove all carriage returns (`r)/ `8 e& Z |8 Y- P' C) w" Y+ {
StringReplace, full_path, full_path, `r, , all0 o2 G- K0 v0 Y6 E
IfInString full_path, \& K6 m$ z |$ o0 i+ \
{
* l5 @* y1 E8 x7 U% T" ~9 f Run, cmd /K cd /D “%full_path%”7 R2 E" o# T( N" Y. P
}4 Y w* o, p& u7 T
else
& V. h1 R9 c' P0 C* O% c4 ?2 } {
8 S7 F* _% Z5 r Run, cmd /K cd /D “C:\ ”
$ G% i7 J4 \; y2 ?3 r! R }
s5 N9 w" p3 V( F2 B }" o; {- t3 B" @( \6 N. r/ D+ j
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 o$ o; s) }$ c7 l7 q0 Y+ u0 E/ g' S 这段小代码肯能有两个你需要修改的地方
, Z: E4 y/ P7 X 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键* ~ N5 L% x& A1 ]& E% T
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 b) i" Y2 A! |- ?4 M |