Sign in to follow this  
Followers 0
nobbe

need help to convert a VBS into autoit

3 posts in this topic

hi

im trying to convert a VBS into autoit

the lower VBS code works fine , excel sheet opens and tag info wll be written

im only interested in the wmplayer object , not the excel .

my object gets created fine, but later it says "The requested action with this object has failed.:"

thanks for help

;===============================================================================
;
;===============================================================================
;
Local $o_object;
Local $rc;

$o_object = ObjCreate("wmplayer.ocx.7")
If Not IsObj($o_object) Then
    MsgBox(0, "error", "error on object creation")
Else
    MsgBox(0, "OK", "object OK")

EndIf

$songnumber = 1;
$song = "test.wma";

;  $rc = $o_object.Convert($infile, $outfile)

$rc = $o_object.mediaCollection.add ($song) ; error ....> ??  ;The requested action with this object has failed.:
MsgBox(0, "rc", $rc)


$rc = $o_object.currentmedia.name
MsgBox(0, "rc", $rc)
$rc = $o_object.currentmedia.duration
MsgBox(0, "rc", $rc)
$rc = $o_object.currentmedia.durationstring
MsgBox(0, "rc", $rc)
oÝ÷ Ù«­¢+Ø(ÌäìÑ¡½É¥¥¹°Y   L½¸¸¸Ý½É­ÌÌÌì((%MÐA±åÈô
ÉÑ=©Ð ÅÕ½ÐíݵÁ±åȹ½à¸ÜÅÕ½Ðì¤(%Íнa0ô]MÉ¥Áй
ÉÑ=©Ð ÅÕ½Ðíá°¹ÁÁ±¥Ñ¥½¸ÅÕ½Ðì¤($(%½a0¹Y¥Í¥±ôQIU(%½a0¹]½É­   ½½­Ì¹($(%ͽ¹ôÅÕ½ÐíÑÍйݵÅÕ½Ðì($(%¥´ÑÑÈ ÄÀ¤(%ÑÑÈ Ä¤ôÅÕ½ÐíÉÑ¥ÍÐÅÕ½Ðì(%ÑÑÈ È¤ôÅÕ½Ðí±Õ´ÅÕ½Ðì(%ÑÑÈ Ì¤ôÅÕ½ÐíÕÑ¡½ÈÅÕ½Ðì(%ÑÑÈ Ð¤ôÅÕ½Ðí ¥ÑÉÑÅÕ½Ðì(%ÑÑÈ Ô¤ôÅÕ½Ðí
ÉÑ¥½¹ÑÅÕ½Ðì(%ÑÑÈ Ø¤ôÅÕ½Ðí¹ÉÅÕ½Ðì($($Ìäì
½±Õµ¸!ÉÌ´(%½a0¹±±Ì İĤôÅÕ½Ðí¥±9µÅÕ½Ðì(%½a0¹±±Ì İȤôÅÕ½Ðí9µÅÕ½Ðì(%½a0¹±±Ì İ̤ôÅÕ½ÐíÕÉѡͽ¹¤¤ÅÕ½Ðì(%½a0¹±±Ì İФôÅÕ½ÐíÕÉÑ¡µ¥¸±Í¤ÅÕ½Ðì($(%½È¤ôÄѼսչ¡ÑÑȤ(%½a0¹±±Ì İЭ¤¤õÑÑÈ¡¤¤(%¹áÐ($(%½a0¹±±Ì Ä°ÄĤôÅÕ½Ðí¥±Í¥éÅÕ½Ðì(%½a0¹±±Ì Ä°ÄȤôÅÕ½Ðí¥±ÑÅÕ½Ðì($(%½¸ÉɽÈÉÍÕµ¹áÐÌäí½Èͽ¹¹µÌÝ¥Ñ ¹ÑÌ£³Ëä($(%ɽÜôÈ($(%Á±åȹµ¥
½±±Ñ¥½¸¹¡Í½¹¤(%Á±åȹÕÉ°õͽ¹($(%½a0¹±±Ì¡É½Ü°Ä¤ôͽ¹(%½a0¹±±Ì¡É½Ü°È¤ôÁ±åȹÕÉɹѵ¥¹¹µ(%½a0¹±±Ì¡É½Ü°Ì¤ôÁ±åȹÕÉɹѵ¥¹ÕÉÑ¥½¸(%½a0¹±±Ì¡É½Ü°Ð¤ôÁ±åȹÕÉɹѵ¥¹ÕÉÑ¥½¹ÍÑÉ¥¹($(%½ÈôÄѼØ(%½a0¹±±Ì¡É½Ü°Ð­¤ôÁ±åȹÕÉɹÑ5¥¹Ñ%ѵ%¹½åѽ´¡Á±åȹµ¥
½±±Ñ¥½¸¹Ñ5¥Ñ½´¡ÑÑÈ¡¤¤¤(%¹áÐ($($Ìäì½Á¸½ÈÁ±å¥¹¸¸($ÌäìÍÐôͼ¹Ñ¥±¡Í½¹¤($

Share this post


Link to post
Share on other sites



I am just taking a guess but maybe try to give the whole path to $song

;===============================================================================
;
;===============================================================================
;
Local $o_object;
Local $rc;

$o_object = ObjCreate("wmplayer.ocx.7")
If Not IsObj($o_object) Then
    MsgBox(0, "error", "error on object creation")
Else
    MsgBox(0, "OK", "object OK")

EndIf

$songnumber = 1;
$song = "test.wma";

;  $rc = $o_object.Convert($infile, $outfile)

$rc = $o_object.mediaCollection.add ($song) ; error ....> ??  ;The requested action with this object has failed.:
MsgBox(0, "rc", $rc)
$rc = $o_object.currentmedia.name
MsgBox(0, "rc", $rc)
$rc = $o_object.currentmedia.duration
MsgBox(0, "rc", $rc)
$rc = $o_object.currentmedia.durationstring
MsgBox(0, "rc", $rc)

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

This works....

As nitekram noted, I included the path in $song.

Also, to get the currentmedia attributes, had to add a few lines. Here's an MSDN reference to the Media player object

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.2.0
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

;===============================================================================
;
;===============================================================================
;
Local $o_object;
Local $rc;

$o_object = ObjCreate("wmplayer.ocx.7")
If Not IsObj($o_object) Then
    MsgBox(0, "error", "error on object creation")
Else
    MsgBox(0, "OK", "object OK")

EndIf

$songnumber = 1;
$song = "c:\\test.wma";

If FileExists($song) Then
    MsgBox(0, "File exists", "Got wma file")
EndIf

;  $rc = $o_object.Convert($infile, $outfile)

$rc = $o_object.mediaCollection.add ($song) ; error ....> ??  ;The requested action with this object has failed.:

If Not IsObj($rc) Then
    MsgBox(0, "error", "error on object creation")
Else
    MsgBox(0, "OK", "object OK")
EndIf

;MsgBox(0, "rc", $rc)

$firstMedia = $o_object.mediaCollection.getAll().item(0) ; <=== add this

;Make the retrieved media item the current media item.
$o_object.currentMedia = $firstMedia;                            <===== and this

$rc = $o_object.currentmedia.name
MsgBox(0, "rc", $rc)
$rc = $o_object.currentmedia.duration
MsgBox(0, "rc", $rc)
$rc = $o_object.currentmedia.durationstring
MsgBox(0, "rc", $rc)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0