pythonCOM with Flash

Bradley Schatz bradley at
Fri Jun 13 10:27:31 CEST 2003

Hi Mark,

thanks for the pointers previously.

I have had a further play using the demos you mention, from within

Here are some notes for things that I dont quite understand..

Makpy finds two typelibraries for Shockwave Flash 1.0 If I look at them
using the MS COM Object viewer, I see that one of them points to an .ocx and
the other points to a .oca

I have modified the example to use flash - the source is

When I use the IID that points to the ocx (begins with D27) I get the
following trace from within pythonwin:

line 310, in RunScript
    exec codeObject in __main__.__dict__
  File "C:\projects\flash\", line 13, in ?
    FlashModule =
gencache.EnsureModule("{D27CDB6E-AE6D-11CF-96B8-444553540000}", 0, 1, 0)
  File "C:\Python23\lib\site-packages\win32com\client\", line
347, in EnsureModule
    tlbAttr = pythoncom.LoadRegTypeLib(typelibCLSID, major, minor,
com_error: (-2147319779, 'Library not registered.', None, None)

When I use the IID that points to the .oca I get the following.

line 310, in RunScript
    exec codeObject in __main__.__dict__
  File "C:\projects\flash\", line 60, in ?
  File "C:\projects\flash\", line 57, in Demo
    f.Create("Flash Player")
  File "C:\projects\flash\", line 42, in Create
    self.ocx.CreateControl("Flash Player", win32con.WS_VISIBLE |
win32con.WS_CHILD, rect, self, 1000)
  File "C:\Python23\lib\site-packages\Pythonwin\pywin\mfc\", line
23, in CreateControl
    self.__dict__["_obj_"] = win32ui.CreateControl(clsid, windowTitle,
style, rect, parent, id, lic_string)
win32ui: CreateControl failed

Any suggestions on what I may be misunderstanding here would be greatly

[test code]
import win32ui, win32con, win32api, regutil
from pywin.mfc import window, activex
from win32com.client import gencache
import sys

#FlashModule =
gencache.EnsureModule("{D27CDB6B-AE6D-11CF-96B8-444553540000}", 0, 1, 0)
FlashModule =
gencache.EnsureModule("{E69E19FB-B24A-4AA2-9E1A-3C6E59F587FC}", 0, 1, 0)

if FlashModule is None:
 raise ImportError, "Flash does not appear to be installed."

class MyFlashComponent(activex.Control, FlashModule.ShockwaveFlash):
 def OnFSCommand(self, command, args):
  print "FSCommend" , command
 def OnProgress(self, percentDone):
  print "PercentDone", percentDone
 def OnReadyStateChange(self, newState):
  print "State", newState

class BrowserFrame(window.MDIChildWnd):
 def __init__(self, url = None):
  if url is None:
   self.url = regutil.GetRegisteredHelpFile("Main Python Documentation")
   self.url = url
  pass # Dont call base class doc/view version...
 def Create(self, title, rect = None, parent = None):
  style = win32con.WS_CHILD | win32con.WS_VISIBLE |
  self._obj_ = win32ui.CreateMDIChild()
  self._obj_.CreateWindow(None, title, style, rect, parent)
  rect = self.GetClientRect()
  rect = (0,0,rect[2]-rect[0], rect[3]-rect[1])
  self.ocx = MyFlashComponent()
  self.ocx.CreateControl("Flash Player", win32con.WS_VISIBLE |
win32con.WS_CHILD, rect, self, 1000)
  self.HookMessage (self.OnSize, win32con.WM_SIZE)
 def OnSize (self, params):
  rect = self.GetClientRect()
  rect = (0,0,rect[2]-rect[0], rect[3]-rect[1])
  self.ocx.SetWindowPos(0, rect, 0)

def Demo():
 url = None
 if len(sys.argv)>1:
  url = win32api.GetFullPathName(sys.argv[1])
 f = BrowserFrame(url)
 f.Create("Flash Player")

if __name__=='__main__':

"Mark Hammond" <mhammond at> wrote in message
news:GV%Fa.2949$GU5.41737 at
> Bradley Schatz wrote:
> > Hi,
> >
> > I am attempting to use Flash as a UI for a python program. I have
> > successfully prototyped this using VB/Flash, and am not trying to
convert it
> > over to work with python.
> >
> > My problem is this, when I run the following code (attached below)
> > happens.
> >
> > I assume that the Flash activex component needs to be placed in some
> > container to be seen, as I am not seeing any window come up when I run
> >
> > Could anyone suggest how to embed this into a container?
> Look at the Pythonwin OCS demos, under the pywin\demos directory.
> wxPython also has some ActiveX container support, but I have never used
> Mark.

More information about the Python-list mailing list