I have a vbs script that plays an mp3, the normal thing would be to call it by dragging the mp3 file to the vbs or specify the mp3 with the command line.
Set objArgs = Wscript.Arguments
if (objArgs.Count = 0) then
Wscript.echo "Necesito un archivo MP3"
WScript.Quit 123
end if
'Wscript.echo "Playing: " & objArgs(0) & "..."
Set objPlayer = createobject("Wmplayer.OCX.7")
With objPlayer ' saves typing
.settings.autoStart = True
.settings.volume = 100 ' 0 - 100
.settings.balance = 0 ' -100 to 100
.settings.enableErrorDialogs = False
.enableContextMenu = False
.URL = objArgs(0)
WScript.Sleep(10000) ' time to load and start playing
'.Controls.Pause() ' stop
End With
WScript.Quit 0
' MsgBox "if WMP is still playing, clicking OK will end it", _
' vbInformation, "WMP Demo finished"
I need to call this code without creating the vbs file to keep things simple. Can this be done with Windows APIs?
For example
callvbsfunction("mycodevbs")
and run it?
When I refer to windows api I mean functions similar to these
MessageBox( 0, "Test", "Title here", MB_OK )
GetSystemMetrics( SM_CXSCREEN )
ShellExecute( 0, "open", "c:\myfile.txt", 0, 0, 1 )
Beep( 1000, 250 )
and more...