Results 1 to 9 of 9

Thread: using webbrowser control and talking to flash

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    7

    using webbrowser control and talking to flash

    I'm doing some browser form automation with the webbrowser control, and I want to have some degree of interactivity with flash forms (that I do not control) on the target webpages. I've read some about java interactions, and flash.external, but Im really still in the dark.

    Really, I just need a pointer in the right direction. What should I be searching on, what documentation should I look at? Of course, sample code would *certainly* not be sneezed at!

    Thanks for any pointers at all,

    bluenote

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: using webbrowser control and talking to flash

    Welcome to the Forums.

    Have you tried searching the adobe site or http://flashkit.com?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Lively Member
    Join Date
    Jan 2008
    Location
    England
    Posts
    113

    Re: using webbrowser control and talking to flash

    If your going to be doing it through a web browser, then you will not be using Visual basic, but probably using Javascript.

    Read this:
    http://www.permadi.com/tutorial/flas...and/index.html

    You will have to either know the ID of the flash control, if the html is missing this im not sure if it will be possible

    Code:
    <object classid="clsid:xxxx-xxxx-xxetc" codebase="http://fpdownload...." width="50" height="50">
    Does not contain the id, so you cant use
    Code:
    javascript:window.document["IDhere"].SetVariable("variable", "value");
    Whereas
    Code:
    <object classid="clsid:xxxx-xxxx-xxetc" codebase="http://fpdownload...." id="example" width="50" height="50">
    You could use:
    Code:
    javascript:window.document["example"].SetVariable("variable", "value");

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    7

    Re: using webbrowser control and talking to flash

    Hi guys

    Robbdog: thanks, this is a great place. I've found some references (on adobe and elsewhere) but as I read it its for app authors more than someone like me who is only in control of one side of the equation. I could be wrong about this. (I'm talking about the flash.external here)

    Seraph: Thanks for replying. I have looked at this site, and its my main reason to believe that this should be possible for me. However, i *am* automating through vb.net and for our purposes operating through IE primarily with use of the webbrowser control. I'm encouraged, but I dont know where to start to try to do the things that are being done in that java article inside VB. ?

    thanks guys

    bluenote

  5. #5
    Lively Member
    Join Date
    Jan 2008
    Location
    England
    Posts
    113

    Re: using webbrowser control and talking to flash

    You can just submit the javascript as a url and it will be ran:

    Code:
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            WebBrowser1.Navigate("http://www.permadi.com/tutorial/flashjscommand/index.html")
        End Sub
    
        Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
            Dim flashID As String = "myFlashMovie"
            Dim flashVar As String = "/:message"
            Dim flashVal As String = "Hi there! This changes the text for you!"
            WebBrowser1.Navigate("javascript:window.document[" & ControlChars.Quote & flashID & ControlChars.Quote & "].SetVariable(" & ControlChars.Quote & flashVar & ControlChars.Quote & ", " & ControlChars.Quote & flashVal & ControlChars.Quote & ");")
        End Sub
    Test that out

  6. #6

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    7

    Re: using webbrowser control and talking to flash

    Seraph,

    What do you think about a scenario where I don't know the variable name(s)? In a situation where its not my website for example?

    thanks

    Cory

  7. #7
    Lively Member
    Join Date
    Jan 2008
    Location
    England
    Posts
    113

    Re: using webbrowser control and talking to flash

    Then you would want to decompile the swf, either using a program like ******* SWF Decompiler or Flare, or use a program like Flasm which will dump the flash asm to a file. You can then look over these files for the variables you want.

    Another way to do it would be to decompress the swf file, and then look through the file for specific string.

    There are many approaches to what you want, you could even brute force/dictionary or dictionary attack (I say attack, just the method)

    If the file is encrypted, you will have to take another approach (or the BF, but that is a long shot, unless you have a reasonable idea of the variables name)
    Other problems may arise with variables that are dynamically generated by the actionscript, as they have no defined name and so therefore cannot be easily found.

    The final thing to say, the best approach to this would be to code a variable scanner in actionscript. I've seen examples of these, however, they are all kept under lock and key.

  8. #8

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    7

    Re: using webbrowser control and talking to flash

    Wow seraph, that's awesome help and very understandable.

    The last thing I'm having trouble with is, this:

    The <embed> tag:
    - the Flash movie must have a name. For example, in the example above, the name is set by name="myFlashMovie"
    - the <embed> tag must include swliveconnect="true" attribute, to turn-on the ability to "connect" with the scripting language (JavaScript).

    It is recommended to use the same value for that both the id and name within the same Flash movie.

    The default seems to be false, and all the pages I'm accessing don't bother to set it. I can imagine doing some kind of local copy, or modifying/inserting into the document stream of a .net webbrowser control ... am I on the right track here or is there a better way to do this?

    thanks very much for lending your insight,

    Cory

  9. #9
    Lively Member
    Join Date
    Jan 2008
    Location
    England
    Posts
    113

    Re: using webbrowser control and talking to flash

    I've never looked at the swliveconnect property before, so I just did a quick test.
    (the thing below is not useful to you, i just got confused by Firefox)

    Using the html:
    Code:
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
      codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0" 
      id="myFlashMovie"
      width=481
      height=86> 
        <param name=movie value="http://www.permadi.com/tutorial/flashjscommand/flips2.swf"> 
        <param name=quality value=high> 
        <param name=play value=false> 
        <param name=bgcolor value=#FFFFFF> 
          <embed
          play=false
          swliveconnect="false"
          name="myFlashMovie"
          src="http://www.permadi.com/tutorial/flashjscommand/flips2.swf"
          quality=high
          bgcolor=#FFFFFF
          width=481
          height=86
          type="application/x-shockwave-flash"
          pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
          </embed > 
    </object >
    (sorry for the crazy formatting)

    I tried running this code through Firefox, and having the swliveconnect property seems to be ignored... so that confused me for a bit as to what you meant, then I tried it in IE and saw what you were talking about...

    So, yeah, I think that editing the file as its loaded/reloading an edited file would be the best way to do it, it shouldnt be hard to do, if you need any more help with that just ask...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width