Sign in to follow this  
Followers 0
gsb

"Flashy" GUI script, first step.

6 posts in this topic

#1 ·  Posted (edited)

"Flashy" GUI script

...well files maybe. But it works!

My first example script... hope it goes well.

Well this is a successful demo due to lod3n's examples mostly.

Many others helped as well and TYVM all.

This is but a side-line to my project but enough to share I think.

The concept is a Flash movie interface as an active control with animations and, well, flashy stuff. (Not the example but the concept. LOL)

The example is a simple GUI window that consists of an HTML page with an embedded Flash movie. The Flash movie can invoke AutoIt functions and the AutoIt script can in turn invoke Flash functions using the Flash player's ExternalInterface.

The HTML page is used here instead of a direct Flash object embed to enable the GUI control resizing; a Flash embed issue for sure. It also enables lod3n's ieonpropertychange triggered events via javascript, a final key in this example.

In addition to the au3 script and the HTML page, there is the .swf or Flash movie. Unfortunately I do not use Flash but rather a cheaper swf generator, SWiSHmax. So the swi is attached but of little value to most I suspect. No fla.

Code: AutoIt

#include <GUIConstants.au3>
#include <IE.au3>

$oIE = ObjCreate("Shell.Explorer.2")
GUICreate( "Flash GUI Example", 640, 480,-1, -1 ,BitOR($WS_SYSMENU, $WS_CAPTION, $WS_SIZEBOX ), $WS_EX_TOPMOST)

$GUIActiveX = GUICtrlCreateObj($oIE, 0, 0 , 640 , 480 )
GUICtrlSetResizing(-1,$GUI_DOCKBORDERS)
GUISetState(@SW_SHOW)

$oIE.Navigate(@ScriptDir & "/gsbIE_1.html")
Sleep(1);; needed for old systems and slow machines
$targetObj = $oIE.document.parentwindow.document.documentElement
$targetObj.setAttribute("params",1)
$handler = ObjEvent($targetObj,"IeEvent_")

While 1
    $msg = GUIGetMsg()
    if $msg = $GUI_EVENT_CLOSE then ExitLoop
Wend

Func IeEvent_onpropertychange()
    $oElement = @COM_EventObj
    if isobj($oElement.params) then
        Msgbox(262208,"Message from Flash!", $oElement.params.cmd & @crlf & $oElement.params.args & @crlf, 5)
        $oElement.params.obj.flashAlert("Flash/JS Alert Message from au3")
        $oElement.params = 1; reset trigger
    EndIf
EndFunc

HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<head>
<style type="text/css" media="screen">
  * {margin:0px;padding:0px;}
  HTML {height:100%;overflow:hidden;}
  body {height:100%;overflow:hidden;}
</style>
&lt;script type="text/javascript">
function au3Direct(cmd,args){
  var targetObj = top.document.parentwindow.document.documentElement;
  targetObj.params = new function(){this.obj=window["gsbMovie"];this.cmd=cmd;this.args=args;}
}
</script>
</head>
<body scroll="no">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,22,0"
id="gsbMovie" width="100%" height="100%">
<param name="movie" value="gsbSM.swf">
<param name="bgcolor" value="#FFFFFF">
<param name="quality" value="high">
<param name="loop" value="false">
<param name="allowscriptaccess" value="always">
</object>
<div><FORM><TEXTAREA ID="gsbTextArea" COLS=80 ROWS=6></TEXTAREA></FORM></div>
</body>
</HTML>

Some of the actionscript/SWiShmax (not fully the same);

...
_global.flashAlert = function(str:String):Void {
    eiCall("alert", str);
};

if((_global.eiAvailable=flash.external.ExternalInterface.available)) {
    _global.eiCall=flash.external.ExternalInterface.call;
    _global.eiCallBack=flash.external.ExternalInterface.addCallback;
    eiCallBack( "flashAlert", _global, flashAlert );
}

...

this.onRelease = function() {
    eiCall("au3Direct", this._name+": test command", "test arguments" );
};

Flash -> Javascript -> AutoIt3 -> Flash

Works like a charm, ...ah, better than what I had anyway.

But any suggestions/improvements are welcome.

postExample.zip

gsb

Edit: 070323 to cleanup the example swi

Edited by gsb

"Did you ever stop to think? ...and forget to restart!"

Share this post


Link to post
Share on other sites



Thanks.

Question 4u lod3n.

In your example, you write your HTML to temp file and navigate to it.

Why does it not work with a document write directly?

Like a navigate to about:blank, write in the HTML and a refresh.

What's next? ...LOL just learning here. Who knows.

gsb


"Did you ever stop to think? ...and forget to restart!"

Share this post


Link to post
Share on other sites

The reason for that was just simplicity. As an example, I didn't want to introduce to a potential viewer more new concepts than required.


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Great lod3n, ...but my question was:

"Why does it not work with a document write directly?

Like a navigate to about:blank, write in the HTML and a refresh."

I tried and could not get it to work. It would not "load" as yours from the HD.

Am I missing a key issue there?

gsb

Edited by gsb

"Did you ever stop to think? ...and forget to restart!"

Share this post


Link to post
Share on other sites

Oh, sorry.

I think that's because about:blank can't be written into. If you want to do it without an intermediate actual file, take a look at _IEBodyWriteHTML


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

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