查看完整版本: 经典脚本求解

lluxury 2008-5-7 19:43

经典脚本求解

'*************************************************************************
,IO~\\@;v0^ ' delete_playing_file.vbs
*X/@3IQ1E4d@ 0r%@a r)SxC
' version: 0.2.4Uve#?i)wD?
' update: 2006.6.19
6N2IJh2w~,y A u 1~WKfg2uJQ$a lW
'               -- Scripted by lifesinger
&Vvg m{ Y\I)G@+gF '
-MV%r |^?"yb}J ' Usage:H/J'[ J f#sU E
'        1. place this script in foobar2000\scripts
U$m7T8b m?? '   2. configure Run sevices (foo_run.dll), see cfg_run.pngo.?G7t*E
'   3. assign a hotkey to this script, such as Ctrl + Del
*a){N `;q uJF9p8c%` '        4. play music now, and use Ctrl + Del to delete ugly songs ^i^HdK!\ Ox
}([S X)kb"k-\
' Home: [url]http://lifesinger.3322.org/[/url]
#g7w;G/W}1kb '*************************************************************************kzYp1n-{l8d)f
Option Explicit
d0H*GUKV q/h^ Const beQuiet    = False        ' If you are annoyed with any confirmation, please change False to True0u9V3f+HK
W$X!n[P6T
'Get commandline arguments, if none, show tips and quit
*C__H'jK Dim objArgs, filepath, songname5DS:|3T:T$e Mx({
Set objArgs = WScript.Arguments
uQ)T,w2cR1A 5Ka qKN:`/c
If objArgs.Count <> 2 Then
J_{.w j*G P"?p         msgbox "delete_playing_file.vbs: delete song on playing. " & _
7q/C;b ^}.`                         vbNewLine & vbNewLine & _|!z&\Y,A C$x\
                   "                          -- by lifesinger, 2006 " & _:uS*z*p~(K`)[M7Re*U
                    vbNewLine & vbNewLine & _
K!e,@5FM8u'Y                    "Usage: delete_playing_file.vbs <file_path> <song_name>" & _
e;s9Ca$F0}@ y0x                     vbNewLine, 64, "About"
8`~.X |;C YD2X         Wscript.Quit8`@Mk0@
Else'_ N` cW
        filepath = objArgs(0)
'PPa9e+wP         songname = objArgs(1)
P3a,m$JO{O%e _ End If
:Fce'A"aTFX:Yn xk-Yr(\-_:XZ7{-qu
'**** DON'T EDIT BELOW **** J*w._K@
'-------------------------== CODE BEGIN ==----------------------------
OO`'c5F%J Dim file_ext
)hX YR*oc$IzX y k file_ext   = LCase(Right(filepath, 3))c4zI8K4uE

` u,r E3uh If Not beQuiet Then
v `lo;eVr         Dim r : r = vbNo
7W(d7zl:i0B.i        
;Z1k x,I&i)?         If file_ext = "cue" ThenF~%h:Z\2CN]4c
                r = MsgBox("This will remove:" & vbNewLine & vbNewLine & songname & vbNewLine & vbNewLine & "from now-playing playlist." & vbNewLine & vbNewLine & "Continue ?", vbYesNo + vbQuestion, "Warning")
0Cy(O `*Ts!v2Z         Else[j6t0~$x
                r = MsgBox("This will delete 1 file:" & vbNewLine & vbNewLine & filepath & vbNewLine & vbNewLine & "Continue ?", vbYesNo + vbQuestion, "Warning") r6l1TA:_0qe7o c
        End If8tZVV.Gl8@Yy
        ;r+Bq*ada2i Q
        If r = vbNo Thenng%n N,](~y2as
                WScript.Quit
P(Y'D2^C&C         End IfNLt.ns,f~:}
       
|Dg5rZ'z End If/fT9o#j*y IWu)C:q
f,d&nN3tke;l\

e,Z9i ]s5DTJ#Eh*O Dim ScriptPath, fso, oShell
xc%j @:~-T4s ScriptPath = Left(WScript.ScriptFullName, (Len(WScript.ScriptFullName) - Len(WScript.ScriptName)))
0QK D*A0v/i.?
J/`ApJ Set oShell = CreateObject("WScript.Shell")
(j Wo vW(o Set fso    = CreateObject("Scripting.FileSystemObject")FMM9hKI*E zxr

t;~%W1h yv If (fso.FileExists(filepath)) ThendCWA&p7W
       
zqO.n"Lr0i%MH:D         If file_ext = "cue" Thenmr wIK2QSq
                oShell.Run Chr(34) & ScriptPath & "..\foobar2000.exe" & Chr(34) & "/command:Remove", 0, True  ' Remove from playlistra$Yg'@P
                WScript.Sleep 100
O!n$B.G9B*G                 oShell.Run Chr(34) & ScriptPath & "..\foobar2000.exe" & Chr(34) & " /next", 0, True            ' play next song
5qgX @ Tf[ o         Else
o%A3y~J C2St:I-e1\                 oShell.Run Chr(34) & ScriptPath & "..\foobar2000.exe" & Chr(34) & " /next", 0, True            ' play next song$J{%k`!sA
                WScript.Sleep 1003| [ e2cqD9h)B
                'del fileN#XN)h$?t:{K
                delete_file filepathJIV I:Y
                'remove dead items
$pU2F-\/hr:u                 oShell.Run Chr(34) & ScriptPath & "..\foobar2000.exe" & Chr(34) & " /command:" & Chr(34) & "Remove dead items"& Chr(34), 0, True *vl&F3Q-d
        End If
v Bw*y _4T n        
5PK+ahD Else
k7M"@"X7G k         If Not beQuiet Then
8L?,j$cX                 MsgBox filepath & " is not existed." & _q7yp7O7D"d.{}
                vbNewLine & _9Q~2g#X3|!B2q[ox
                "Run Services(foo_run.dll) maybe is configured improperly. " & _ kZR$LX:A*sU#M4r
                vbnewline & _rR7G%}3X5P4y*q F
                "Please check it -_-", 48, "error"0G-e(F6Jh JLj"X
        End If
/V^dV cc!b        
'i#L*P:jo2U h(|\4D End If
b-}8Rgs kZ;q
xI4y5V*BXu Set oShell = Nothing
Pb2_*H%MN H Set fso    = Nothing
aA?:v1e h'}PK;Jy"L[
WScript.Quit
,g xS,U'[!K '-------------------------== CODE END ==----------------------------
gUE#V7v n.J
!JY3L w? JX g8~F up _f
'--------------------------------------- \%l^M8r |H e/V.^7j
Sub delete_file(filespec)
@8P3HT`2}+V4W         On Error Resume Next
5y:Lg8N#Z*y?4h         Err.Clear
}^Vgn7U xL }         o3\ Y2e&OZW
        fso.DeleteFile filespec, True
s4qge,Jr f+mY`{}        
dZ'qn k~4^ Z         If Err.Number <> 0 Then 8M dw lyf.F
        t2ayS5MG
                ' maybe filespec is the last file in the playlist'H*HW"B&Pa
                ' so first stop it, and try delete again
2NvZ+^w2P                 oShell.Run Chr(34) & ScriptPath & "..\foobar2000.exe" & Chr(34) & " /stop", 0, True  ' stop
?8w.wIIj'|                 WScript.Sleep 100%EY~;I1MqN#c"` k
                Err.Clear:yT'rN PH
                fso.DeleteFile filespec, Truersd1nM7T
               
i$Z#S(t(m&vv                 If Err.Number <> 0 Thenw)K&Gal o5d Mz"T
                        If Not beQuiet Then
+w |'s B[k `X'Oh                                 MsgBox "Delete " & filespec & " failed." & vbNewLine & "I don't know why :(", 48, "error"
E!]"g U8r^k                                 End If+m&F.bx*F0e:Sz
                End Ifh!H*o/vl Wx7A
+_X!EpC EL n(kH
        End If
:K}Fs:BM         xCD8{i'g,PJ*A
        On Error Goto 0!_'x:Fi0~|M/S
End Sub
S#n,Qc5y.j#n#{ '---------------------------------------
JH%d_F
8]w1j E9h&e Z(b6|!}i-b 这个脚本的作用是把foobar2000正在播放的歌删除,我想把它的作用改为将播放中的歌曲移到D:\music,自己试了几次都失败了,求大家帮忙:W#QH0Gu'v:X,T
!VW3sA|tQ{e
[[i] 本帖最后由 lluxury 于 2008-5-7 19:51 编辑 [/i]]

陈兆良 2008-5-7 20:22

好难啊1~

chinajuan2 2008-5-14 21:49

有点晕~~~~~~~~

shamolvzhou 2008-5-14 23:18

刚刚接触脚本,还不太懂~!

cnmdb 2008-6-8 13:13

要慢慢看动呵

setthyfree 2008-6-16 14:58

难!會的幫一下

1000tt 2008-7-7 09:55

好难啊 我也是刚刚接触脚本 学习中
页: [1]
查看完整版本: 经典脚本求解