打印

[求助] 经典脚本求解

经典脚本求解

'*************************************************************************8 |6 U" V% R4 N" r6 f: n' X
' delete_playing_file.vbs
- ]( @6 ^! a' v0 s4 g/ C- }" f2 ?( F$ h0 @& D; T
' version: 0.2.4
2 e& X8 V% t- Y3 i' ^5 `( i' update: 2006.6.19: e8 O( |: L: B! w, j

, @3 \* `$ i# ~2 M+ D' -- Scripted by lifesinger, W, n; _$ o. f# d0 x: C
'" \6 ~& ~9 M$ T4 r" s+ o
' Usage:+ A5 c: B3 I# r; Q
' 1. place this script in foobar2000\scripts
! g, B0 c4 _/ J- ^( ]' 2. configure Run sevices (foo_run.dll), see cfg_run.png/ Y: K3 Q8 B! ]' g% x
' 3. assign a hotkey to this script, such as Ctrl + Del! Q4 u. p2 ?. m1 l2 ], r& {9 B
' 4. play music now, and use Ctrl + Del to delete ugly songs ^i^- ^# O. O: E- L3 a8 \

- X0 p j5 o2 ?+ s; W; U' ?' Home: http://lifesinger.3322.org/
; _3 j% A" }2 F'*************************************************************************4 Z5 @6 y$ b3 C4 X8 q
Option Explicit. e8 B: b) ]# m/ t( I& X* o
Const beQuiet = False ' If you are annoyed with any confirmation, please change False to True+ g& G5 M# z1 |) I% j! I2 f) g
2 d: ~ ?2 s: M
'Get commandline arguments, if none, show tips and quit
8 o# \! Q3 a) m- y. l4 \6 m UDim objArgs, filepath, songname
, A2 [' h9 g& t( u- {' w `: T( ESet objArgs = WScript.Arguments
' p9 E+ ^: H* w
- {# f p# G/ D$ d* R: qIf objArgs.Count <> 2 Then# B& S0 d! t: }, g) e8 B- V
msgbox "delete_playing_file.vbs: delete song on playing. " & _
: b/ n5 f4 a2 B6 Y vbNewLine & vbNewLine & _* Z9 j% R" H( ?% U; o. {
" -- by lifesinger, 2006 " & _
, R* [3 T4 C7 Z- F/ U3 T vbNewLine & vbNewLine & _& s) C T& K9 c+ i9 N9 q. {
"Usage: delete_playing_file.vbs <file_path> <song_name>" & _
) k* Y# |9 U0 j, f vbNewLine, 64, "About"+ Y1 m2 I5 K2 M- q C* x
Wscript.Quit8 C5 B$ p& V5 ^- Q6 r' b+ X
Else
9 @# N: p) |7 O filepath = objArgs(0)
4 @ M) x7 A7 W/ b songname = objArgs(1)
: O- |4 h A6 YEnd If
# B6 e- b8 |) P2 z
5 n- S( y& k# }1 G+ I'**** DON'T EDIT BELOW ****5 k* q8 @# a1 Q
'-------------------------== CODE BEGIN ==----------------------------1 U& q3 b1 k- G$ z
Dim file_ext
# V4 i9 {8 O( x9 H4 s1 ofile_ext = LCase(Right(filepath, 3))
) A/ @- W! S/ h
: x" |( l0 a# W/ |1 L2 WIf Not beQuiet Then
4 C) H/ \' C( D9 v/ o' j Dim r : r = vbNo
6 P( e: q5 E7 L, }1 }* j. r, @
4 s5 s; |- b n- A& x If file_ext = "cue" Then
" J4 ^" \; H/ l r = MsgBox("This will remove:" & vbNewLine & vbNewLine & songname & vbNewLine & vbNewLine & "from now-playing playlist." & vbNewLine & vbNewLine & "Continue ?", vbYesNo + vbQuestion, "Warning")+ y* i1 V7 ?. \& P6 m6 r: `
Else9 F' K4 @+ l/ d2 r
r = MsgBox("This will delete 1 file:" & vbNewLine & vbNewLine & filepath & vbNewLine & vbNewLine & "Continue ?", vbYesNo + vbQuestion, "Warning")
! [4 _. V& f# f- A: ~! x End If' v# R" q. W, n7 U0 Z# V
* J& E9 }% k/ q
If r = vbNo Then
% D- W, p9 x; P& p! } WScript.Quit
C# ?- S$ ^7 E2 _$ g End If
/ b4 J# `3 M( @/ ^2 F ( a' D( S" g( I9 e5 p+ ?4 Q* a/ }
End If" Q8 X7 |- U. d, L9 }. z0 s
+ i6 U5 @, Y5 V3 }- ?0 b
* @0 ~" {" ]6 x1 h
Dim ScriptPath, fso, oShell6 o8 j0 j! |9 h/ ~: g1 r k
ScriptPath = Left(WScript.ScriptFullName, (Len(WScript.ScriptFullName) - Len(WScript.ScriptName)))
+ s3 t& Y& P! ^7 D1 d# i
1 [5 p7 R+ I6 B6 A" uSet oShell = CreateObject("WScript.Shell")
7 F+ y4 W' |% j) b* ]# jSet fso = CreateObject("Scripting.FileSystemObject")4 K! G X9 F: {: P! i: N

0 y: w8 B- ~7 }' [If (fso.FileExists(filepath)) Then% [! @/ `" D O

! g( P4 U4 c6 r* }" _; _ R' n u If file_ext = "cue" Then
$ ?1 w( f' u. B7 T0 b; N oShell.Run Chr(34) & ScriptPath & "..\foobar2000.exe" & Chr(34) & "/command:Remove", 0, True ' Remove from playlist
6 c# m$ l7 M$ N: l& Q/ M WScript.Sleep 100
; y3 G' z0 _+ D) A oShell.Run Chr(34) & ScriptPath & "..\foobar2000.exe" & Chr(34) & " /next", 0, True ' play next song" r+ n |4 G. a& O9 v7 R
Else; c; p! @) g* W8 [+ G- ?4 y" Y) f
oShell.Run Chr(34) & ScriptPath & "..\foobar2000.exe" & Chr(34) & " /next", 0, True ' play next song
# S$ Q' A3 D1 _ WScript.Sleep 100% Z4 \% j# T' E6 x; W
'del file
; Q0 k5 V" {* G; W. `7 N, L k delete_file filepath
) R5 E' |4 U4 l 'remove dead items
1 w3 Q/ s; W% Z/ F) q0 L oShell.Run Chr(34) & ScriptPath & "..\foobar2000.exe" & Chr(34) & " /command:" & Chr(34) & "Remove dead items"& Chr(34), 0, True a2 i2 n/ W ^7 j. V
End If$ ~ o6 w7 p! P

! Y+ a" F4 m0 v5 y( H- I8 jElse
$ W! L1 f. \' K S If Not beQuiet Then5 J6 J$ d4 J5 \
MsgBox filepath & " is not existed." & _
% H$ i, L f: r5 v2 l* u vbNewLine & _4 g0 p+ J. |) m/ I0 `7 W$ ?4 U
"Run Services(foo_run.dll) maybe is configured improperly. " & _$ Z$ l5 Z: k! h5 F8 E
vbnewline & _/ b- m; E3 s! v; b: k
"Please check it -_-", 48, "error"
+ f1 E. E" ~) H+ m9 R! @5 o* e End If& W7 ~6 a. @, F( L# c- _: k

# C/ \, e( {# w" y( z& CEnd If
) y& b. P$ J4 C* h( b! ?
$ _+ V# T, p$ N& {4 t* u2 x( D5 jSet oShell = Nothing* z! p- I1 p2 x' m0 ], y+ @. ]
Set fso = Nothing
) K6 h9 D) |6 V8 f# Y4 ~+ l
: P0 L3 y- p! ?# b- C- ~3 s7 `# XWScript.Quit. n9 t8 ]! L* W/ i
'-------------------------== CODE END ==----------------------------
0 N3 E- H. l( H; v4 p U7 V( h! {$ @2 T

7 t# O( O, f* N, I'---------------------------------------( ^1 ?3 ]7 M [/ b2 P. z' e' k) f' A
Sub delete_file(filespec)' R, F G6 i; n7 d. N
On Error Resume Next
8 T w! C/ m% N Err.Clear
( E" o; R: A# X * K7 W* L$ i7 k0 Z
fso.DeleteFile filespec, True
6 `* m/ d+ z" Q9 @- A" {2 e0 e 8 _' s3 ~$ D+ m3 v
If Err.Number <> 0 Then
6 ^2 X! L% ]6 y0 N4 |7 f
* @/ J* Z7 @) T' c! Y ' maybe filespec is the last file in the playlist- c J5 s7 t* g# _/ @
' so first stop it, and try delete again( J3 I- E3 X( q
oShell.Run Chr(34) & ScriptPath & "..\foobar2000.exe" & Chr(34) & " /stop", 0, True ' stop
$ m) J! M/ I {6 S; Y WScript.Sleep 100$ Q4 F; K" {5 S; F, h T f
Err.Clear
~. B; K: a- k L fso.DeleteFile filespec, True
* Q; A" @! Q; s g* I 8 @# v, t/ I0 K9 N8 n, I' P9 _
If Err.Number <> 0 Then
- k/ L! U v% U' G If Not beQuiet Then) L5 O/ ]0 y8 n2 D( @9 @4 k
MsgBox "Delete " & filespec & " failed." & vbNewLine & "I don't know why :(", 48, "error"
( `$ L& {% W' ]! L& E4 c4 s End If3 j) t% c- t6 F, G1 N2 u; T6 o6 A
End If
6 o; j8 ^4 `2 j% Y* l2 r
4 H4 |& b. Q3 p. G* c End If
: L1 v% c: ] v
' P/ A: o9 \4 h9 \ On Error Goto 0
2 Z$ p: G# N1 A, U+ b2 _End Sub$ a, a! v9 z2 a) h* J8 X# a7 M
'---------------------------------------
9 Z6 L1 `( y: ?$ ~, F P7 D% @% O
& D5 g% D3 B; n2 ]2 b这个脚本的作用是把foobar2000正在播放的歌删除,我想把它的作用改为将播放中的歌曲移到D:\music,自己试了几次都失败了,求大家帮忙' w' g$ O0 j, [

0 Z, E+ E1 h$ \ ^( V5 T! j[ 本帖最后由 lluxury 于 2008-5-7 19:51 编辑 ]
2008.05.30 MCSE 70-298 784
2008.05.30 MCSE 70-294 794
2008.05.30 MCSE 70-236 812
2008.05.18 MCSE 70-293 820
2008.05.18 MCSE 70-291 778
2008.05.13 MCSE 70-290 885
2008.05.13 MCSE 70-620 815
2008.04.12 MCSE 梦的开始

TOP

好难啊1~

TOP

有点晕~~~~~~~~

TOP

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

TOP

要慢慢看动呵

TOP

难!會的幫一下

TOP

本功能由奇虎搜索实现

相关主题

标题 作者 最后发表
[站外] 几种主流的渲染软件   [转帖] Archer 2008-05-29
[站外] 几千G视频教程   [转帖] download2009 2008-06-22
点击阅读更多关于的相关帖子  更多相关主题