Sign in to follow this  
Followers 0
kjactive

New Embedded activeX object - Shockwaveplayer

16 posts in this topic

This is a small example to include a shockwaveplayer into autoit3 gui to play nice animated .swf files - I provided one on my site to play around with, could also be on disk...

; Author:   Kåre Johansson
; AutoIt Version: 3.1.1.55
; Description: Very Simple example: Embedding ShockwaveFlash object
; Date: 4 jul 2005

#include <GUIConstants.au3>
$oRP = ObjCreate("ShockwaveFlash.ShockwaveFlash.1")

GUICreate ("Embed ShockwaveFlash control Test", 320, 265, -1, -1,BitOr($WS_OVERLAPPEDWINDOW,$WS_VISIBLE,$WS_CLIPSIBLINGS))
$TagsPageC = GuiCtrlCreateLabel('Visit Tags Page', 5, 245, 100, 15, $SS_CENTER)
GuiCtrlSetFont($TagsPageC,9,400,4)
GuiCtrlSetColor($TagsPageC,0x0000ff)
GuiCtrlSetCursor($TagsPageC,0)
$1C = GUICtrlCreateButton('Showall',105,240,70,20)
$2C = GUICtrlCreateButton('NoBorder',175,240,70,20)
$3C = GUICtrlCreateButton('NoScale',245,240,70,20)

$GUIActiveX = GUICtrlCreateObj( $oRP, 10, 10 , 300 , 225 )
$LinkoRP = ObjEvent($oRP,"IEEvent_","Preview"); this is a dummy event handle

With $oRP; Object tag pool
    .Movie = 'http://www.sitecenter.dk/latenight/nss-folder/rapports/Test.swf'; the wave file from inet / could be on disk
    .ScaleMode = 3;0 showall, 1 noborder, 2 exactFit, 3 noscale
    .bgcolor = "#000000"; change background color to white FFFFFF
    .Loop = True
    .wmode = "Opaque"; Opaque / transparent
;.Stop / .Play
EndWith

GUISetState ();Show GUI

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $TagsPageC
            Run(@ComSpec & ' /c start http://www.myplugins.info/guids/typeinfo/typeinfo.php?clsid={D27CDB6E-AE6D-11CF-96B8-444553540000}','', @SW_HIDE)
        Case $msg = $1C
            $oRP.ScaleMode = 0
        Case $msg = $2C
            $oRP.ScaleMode = 1
        Case $msg = $3C
            $oRP.ScaleMode = 3
    EndSelect
WEnd
    
GUIDelete ()
Exit

The component use swflash.cab in system32 but it's probably already there...

kjactive :)

Share this post


Link to post
Share on other sites



:)

Share this post


Link to post
Share on other sites

hmm i get error

---------------------------

AutoIt Error

---------------------------

Line 7 (File "C:\Documents and Settings\Counter-Strike\Desktop\swf.au3"):

$oRP = ObjCreate("ShockwaveFlash.ShockwaveFlash.1")

$oRP = ^ ERROR

Error: Unknown function name.

---------------------------

OK

---------------------------

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

#include <GUIConstants.au3>
$oRP = ObjCreate("ShockwaveFlash.ShockwaveFlash.1")

GUICreate ("Flying Gonzo", 820, 600, -1, -1)

$GUIActiveX = GUICtrlCreateObj( $oRP, 10, 10 , 800 , 580)
$LinkoRP = ObjEvent($oRP,"IEEvent_","Preview"); this is a dummy event handle

With $oRP; Object tag pool
    .Movie = 'http://muppets.go.com/games/muppets-flyinggonzo.swf'; the wave file from inet / could be on disk
    .ScaleMode = 2
    .bgcolor = "#000000"; change background color to white FFFFFF
    .Loop = True
    .wmode = "Opaque"; Opaque / transparent
;.Stop / .Play
EndWith

GUISetState ();Show GUI

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd
    
GUIDelete ()
Exit

#include <GUIConstants.au3>
$oRP = ObjCreate("ShockwaveFlash.ShockwaveFlash.1")

GUICreate ("Bloody Pingu", 820, 600, -1, -1)

$GUIActiveX = GUICtrlCreateObj( $oRP, 10, 10 , 800 , 580)
$LinkoRP = ObjEvent($oRP,"IEEvent_","Preview"); this is a dummy event handle

With $oRP; Object tag pool
    .Movie = 'http://mirrored.flabber.nl/bloody.pingu/bloody.pingu.swf'; the wave file from inet / could be on disk
    .ScaleMode = 2
    .bgcolor = "#000000"; change background color to white FFFFFF
    .Loop = True
    .wmode = "Opaque"; Opaque / transparent
;.Stop / .Play
EndWith

GUISetState ();Show GUI

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd
    
GUIDelete ()
Exit
Edited by Mosquitos

Sapiente vince, rex, noli vincere ferro!

Share this post


Link to post
Share on other sites

Those are awesome, but AutoIt crashes when I close the dialog. Maybe it's not properly deleting the object or something.


My UDFs: ExitCodes

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

You need to free the activex object like this example

#include <GUIConstants.au3>
$oRP = ObjCreate("ShockwaveFlash.ShockwaveFlash.1")
GUICreate ("Bloody Pingu", 820, 600, -1, -1)
$GUIActiveX    = GUICtrlCreateObj( $oRP, 10, 10 , 800 , 580)

With $oRP; Object tag pool
    .bgcolor = "#000000"; change background color to white FFFFFF
    .Movie = 'http://mirrored.flabber.nl/bloody.pingu/bloody.pingu.swf'; the wave file from inet / could be on disk
    .ScaleMode = 2
    .Loop = True
    .wmode = "Opaque"; Opaque / transparent
;.Stop / .Play
EndWith

GUISetState ();Show GUI

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

$oRP = 0; FREE THE OBJECT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
GUIDelete ()
Exit

That's all...

kjactive :whistle:

Edited by kjactive

Share this post


Link to post
Share on other sites

Hi, is it possible to receive the FSCommand Events of the Shockwaveplayer?

In VB it works this way...

In C# its implemented this way...

I can see that there is a way to redirect the events to UDFs but I could'nt figure out where to start. Hope you could help, this would be a great addition to AutoIT as it would be a very very powerful FlashPlayer if someone could find a solution.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

I'm not shure that the FSCommand function is part of the ShockwaveFlash com obj but there is other activex com obj as SWCtl.SWCtl.7 ( SwDir.dll ) or FlashFactory.FlashFactory.1 ( Flash.ocx ) as the FSCommand is stated as part of the player and there are no such function documentated related to ShockwaveFlash com obj but I found some information

exec

The exec command is used to launch an external application.

In Macromedia Flash MX the external application must be in a subfolder named 'fscommand'. This subfolder must be in the same directory as the projector which uses the fscommand action. This security restriction helps prevent malicious use of the exec option.

The following script launches the Windows application someApplication.exe , which is in the fscommand folder on the same level as the projector:

on (release) {

fscommand ("exec", "someApplication.exe");

}

Note: The fscommand subfolder path is not used in the argument. Place someApplication.exe inside the fscommand folder, but just use the name of the application in the argument.

In Macromedia Flash 5 the argument to exec must be the absolute or relative path to the application to launch. If no path is specified, Macromedia Flash assumes the same folder in which the projector resides. The following script launches the Windows application someApplication.exe , which is in the same folder as the projector:

on (release) {

fscommand ("exec", "someApplication.exe");

}

These players are a bit different and ShockwaveFlash.ShockwaveFlash.1 com obj just had some easy information available and I could not find any documentations on the other players...

Look up this google search address and snoop around for information like for the 'exec' function but remember that these players is mostly target to web browse with html or java...

http://www.google.dk/search?hl=da&q=fscommand&meta=

kjactive ;)

Edited by kjactive

Share this post


Link to post
Share on other sites

Great job with the shockwave, maybe you can help me with something.

I modified some of your code in an attempt to embed DCR (shockwave director) files. I can play the file successfully, but even when the window is focused, keypresses (most of them) do not go through.

Any thoughts on how to resolve? I dont have my source right now, but i can post it later, if it helps....

Also, any comment on whether an autoit program would be able to interface with director movies (not including simulated keyboard/mouse)?

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Great job with the shockwave, maybe you can help me with something.

I modified some of your code in an attempt to embed DCR (shockwave director) files.  I can play the file successfully, but even when the window is focused, keypresses (most of them) do not go through.

I asume that it's the shockwave director plug-in you are trying to embed - I do not have any experiment with this obj but these plugins are a bit different, with special features and special tagets and SvenPs activex function are not 100% functional in any conditions as there are objects that just can't be embedded even though they work greatly with VB

Any thoughts on how to resolve? I dont have my source right now, but i can post it later, if it helps....

Well if some key presses work and other don't I say that you have embedded the obj alright and it's SvenP activex functions that do the trick but attach a script and I'll look into it...

Also, any comment on whether an autoit program would be able to interface with director movies (not including simulated keyboard/mouse)?
You can do almost any key manipulations with autoit but in the same time autoit do some blocking on special keys as there are buildin functions like 'ESC' that terminate a default autoit running script but provide a script and I'll look into it more detailed ( actually the embedded com obj ID would help me a lot )...

kjactive ;)

Edited by kjactive

Share this post


Link to post
Share on other sites

Hi,

Thanks for the info, it guided me to the right path. I also now have a Flash SWF component receiving the FSCommand events.

#include <GUIConstants.au3>

$swfObj = ObjCreate("ShockwaveFlash.ShockwaveFlash.1")

$winObj = GUICreate("AutoIT Flash Player", 550, 300, -1, -1)

$swfActiveX = GUICtrlCreateObj( $swfObj, 0, 0 , 550, 300)

$swfObjEvents = ObjEvent($swfObj,"FSCommand")

$swfObj.Movie = @WorkingDir & '/AutoItFlashPlayer.swf'
$swfObj.ScaleMode = 3
$swfObj.bgcolor = "#FFFFFF"
$swfObj.Loop = True
$swfObj.wmode = "Opaque"

Func FSCommand($type,$command,$arguments)
    If $type = "FSCommand" Then
        MsgBox(0,"AutoIT", $command & ":" & $arguments)
        If $command = "autoit" Then
            $swfObj.SetVariable("AutoItReply", "[" & @UserName & "] " & $arguments)
        EndIf
    EndIf
EndFunc


GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

GUIDelete ()
Exit

Attached is the prototype.

Now I also get the same issue with the keypresses. My major concern is that I lost the {ENTER} key. In the flash is a TextArea, TextInput and a Button. You can click on the button to send whatever is in the TextInput to the "AutoIT Wrapper". I also placed a listener for the TextInput's {Enter} KeyPressed Event, my only problem is flash can't seem to receive the event anymore. For a straight forward test, the TextArea is a multi line TextArea where you can do paragraphs of text by pressing the {Enter} key, it also doesnt seem to work there.

Is there a way to tell autoit to ignore all window-etc events and just let the flash component have the priority?

If you can't access the file, I could email it to you, if you'd want to see it.

AutoItFlashPlayer.zip

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

I looked at your script and that's true the 'ENTER' key do not function in the multi line TextArea - but this is probably the case, the multi line TextArea is not a common text area control but looks to me as a RICH text area that do have this behave and as this is auto created by the shockwave com obj you got to get this control ID to manipulate with it. RICH objects has the behave of being as in one line, try to fillin a compleat line and you will see that the control do a LF and start on a new line and you can move around this control with arrow keys, just like a RICH control and future more do a copy/paste - the control do not use common ascii text too - well you can do one or two things...

Lookup documentation and find the ID/tags related to this control, if there are any as some buildin controls are just buildin for the purpose to be internal use only - and this looks like the case to me but sometimes one see that the programmers has split the system up in different com objs all available as independent libraries that can be embedded sepparately...

Use autoit3 special features and try to snap out some ID ( functions like ControlGetHandle ) but I daut that this would succede

Do your own multiline text area control above the RICH and let this do the interaction...

Not much but the best I could do - if you got questens about a RICH com obj there is an example somewhere in this nice forum...

NOTE: I noticed that you forgot to free your object at the end of your script ( $swfObj = 0 )...

kjactive ;)

Edited by kjactive

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