Jump to content

gsb

Active Members
  • Posts

    144
  • Joined

  • Last visited

About gsb

  • Birthday 10/17/1948

Profile Information

  • Location
    Seattle
  • WWW
    http://www.GypsyTrader.com

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

gsb's Achievements

Adventurer

Adventurer (3/7)

0

Reputation

  1. Martin - That is a timeout for loading. Sounds like it did not get connected up with javascript in your browser. GtaSpider - Yeah fake I do not know how to get that data from the player. gsb
  2. Using this approach (BTW very nice UDF there CFire) is there a way to build a dynamic "spectrum analyzer" ...equalizer? Are the hooks accessible in the Windows Media Player Com Object to do such? Thanks, gsb
  3. Thanks lod3n. And thanks for so much help along the way. gsb
  4. DeskTopSWFs - Widgets for the desktop ...of your own design using Flash. Introduction This project has been to develop "stand alone" application out of Flash movie content. I found it best to use a GUI with a single _IECreateEmbedded control. This works better than the ObjCreate("ShockwaveFlash.ShockwaveFlash.1") control due to some bad behavior of the Flash Player such as; re-draw hick-ups, refusal to re-size properly and some focus related issues I could not sort out. Embedding the movie in a small HTML script allows the browser to mitigate such annoyances. It also opens the possibility of far more robust web rich desktop applications and CD based applications for example anyway. Goals The main goal was seamless two way communications between the Flash movie and the AutoIt GUI wrapper script. Flash's "External Interface" provides AutoIt with direct access to the movie's ActionScript exposing all of the movie's functionality and capabilities. And lod3n's "event bridge" enables Flash to trigger events that are then captured and processed by the AutoIt wrapper script. Although asynchronous, this combinations seems to work efficiently so far. Some of the other goals included "look-n-feel" like: full screen applications without any window dressings - chromeless. And GUI transparency with click-through to the desktop capability. Simple GUI tricks enable both of these capabilities and of course even more. Requirements This approach requires three files: an AutoIt GUI wrapper script,a compiled Flash movie (.swf) file, anda 1x1 pixel gif file of the transparent color.I usually compile the AutoIt using "FileInstall" for the other two files to make a single exe out of the three. The AutoIt script is still changing some and ultimately I would like to make a user interface allowing someone to simply pick and choose a couple of options and spit them out an exe of their Flash movie. Comments Note that I example AutoIt assisting Flash to create stand alone applications. But this could just as easily be a Flash movie acting as an AutoIt GUI: it just depends on your point of view, no? Examples I posted an earlier example of a clock face here: Clock Example This is an example of a streaming radio using CFire's Windows Media Player example. The radio player is dragable and I added a context menu along with two hot keys: 1) <esc> to exit (also double click will work) and 2) <ctl><shift>V to toggle visibility. Here I also added the "inetGet" to avoid file issues in this example. Restrictions The example runs on any windows PC with IE and the Flash player plug-in version 8 or better for IE as well as the Windows Media Player installed. #include <IE.au3> Global Const $GUI_EVENT_MOUSEMOVE = -11 Global Const $GUI_EVENT_CLOSE = -3 Global Const $WS_POPUP = 0x80000000 Global Const $WS_EX_TOPMOST = 0x00000008 Global Const $WS_EX_TOOLWINDOW = 0x00000080 Global Const $WS_EX_LAYERED = 0x00080000 Global Const $GUI_DOCKBORDERS = 0x0066 ; ...setup Initializations Opt("GUIOnEventMode", 1) Opt("GUICloseOnESC", 0) Opt("TrayIconHide", 1) _IEErrorHandlerRegister() Dim $guiWinTitle = "DeskTopSWFs" Dim $Version = "v070808a" Dim $AboutText = $guiWinTitle & " " & $Version & " " & @LF & "by gsb" & @LF ;;----------------- from: Misc.au3 - _Singleton for $guiWinTitle DllCall("kernel32.dll", "int", "CreateMutex", "int", 0, "long", 1, "str", $guiWinTitle) Dim $lastError = DllCall("kernel32.dll", "int", "GetLastError") If $lastError[0] == 183 Then MsgBox(266288, $guiWinTitle & " - Error", "...already running. Aborting. ", 8) Exit EndIf HotKeySet("^+v", "_ToggleVisibility") HotKeySet("{ESC}", "_Exit") ;; last chance exit ;; **** for example post only InetGet("http://www.GypsyTrader.com/SWiSHmax/au3Examples/mainSWF.swf",@ScriptDir&"\mainSWF.swf") InetGet("http://www.GypsyTrader.com/SWiSHmax/au3Examples/required.key",@ScriptDir&"\required.key") #region ;; ...setup files and build HTML for IE inatance Local $swfFilename = @TempDir & "\mainSWF.swf" FileDelete($swfFilename) FileInstall("mainSWF.swf", $swfFilename) Local $keyFile = @TempDir & "\required.key" FileDelete($keyFile) FileInstall("required.key", $keyFile) $sHTML = '<html><head><title>DeskTopSWFs by gsb</title>' & @CRLF $sHTML &= '<meta name="author" content="gsb">' & @CRLF $sHTML &= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' & @CRLF $sHTML &= '<style type="text/css">' & @CRLF $sHTML &= '* {margin:0px;padding:0px;}' & @CRLF $sHTML &= 'HTML {height:100%;overflow:hidden;border:0px;background-color:#FEDDEF}' & @CRLF $sHTML &= 'body {height:100%;overflow:hidden;border:0px;background-color:#FEDDEF}' & @CRLF $sHTML &= '</style>' & @CRLF $sHTML &= '<script type="text/javascript">' & @CRLF ;; Bridge Event sequencer javascript compressed @ http://dean.edwards.name/packer/ $sHTML &= 'window.au3EventsQueue=new Array();window.au3Interval=null;function au3EventsSequencer(){if(window.au3EventsQueue.length){if((o=document.getElementById("eventBridge")).bridge==""){var data=window.au3EventsQueue.shift();o.bridge=new function(){this.cmd=data.cmd;this.cb=data.cb;this.args=data.args}}}return(window.au3EventsQueue.length)};function au3Event(cmd,args){window.au3EventsQueue.push({cb:((t=cmd.split("|")).length>1?t[1]:""),cmd:t[0],args:args});au3EventsSequencer()};function au3Direct(cmd,args){document.getElementById("eventBridge").bridge=new function(){this.cb=(t=cmd.split("|")).length>1?t[1]:"";this.cmd=t[0];this.args=args}};' & @CRLF $sHTML &= '</script>' & @CRLF $sHTML &= '<base href="file:\\' & @ScriptDir & '\" />' & @CRLF $sHTML &= '</head><body scroll="no">' & @CRLF $sHTML &= '<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%">' & @CRLF $sHTML &= '<param name="bgcolor" value="#FEDDEF">' & @CRLF $sHTML &= '<param name="quality" value="high">' & @CRLF $sHTML &= '<param name="loop" value="false">' & @CRLF $sHTML &= '<param name="menu" value="true">' & @CRLF $sHTML &= '<param name="allowscriptaccess" value="always">' & @CRLF $sHTML &= '<param name="wmode" value="transparent">' & @CRLF $sHTML &= '<param name="base" value="file://' & @ScriptDir & '\">' & @CRLF $sHTML &= '<param name="movie" value="' & $swfFilename & '">' & @CRLF ;; $sHTML &= '<param name="flashvars" value="debug=true">' & @CRLF $sHTML &= '</object><input type="hidden" id="eventBridge" gsb=""></body></html>' & @CRLF #endregion #region;; ...Core GUI code - transparent, Kiosk mode IE instance loaded w/ $sHTML Local $height = 100, $width = 300 Local $mainGUI = GUICreate($guiWinTitle, $width, $height, -@DesktopWidth, 0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST + $WS_EX_LAYERED) Local $ieOBJ = _IECreateEmbedded() Local $ieCTL = GUICtrlCreateObj($ieOBJ, 0, 0, $width, $height) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUICtrlSetResizing($ieCTL, $GUI_DOCKBORDERS) _IENavigate($ieOBJ, 'about:blank') _IEDocWriteHTML($ieOBJ, $sHTML) GUICtrlCreatePic($keyFile, 0, 0, 0, 0, -1) AdlibEnable("_LoadAbort", 10000) Sleep(10);; needed for old/slow sytems/machines Local $oTarget = $ieOBJ.document.getElementById ("eventBridge") Local $handler = ObjEvent($oTarget, "IeEvent_") Local $movie = 0, $mousePos Local $WMStation, $WMVol = 100, $WMPlayer = ObjCreate("WMPlayer.ocx") Local $WMStates[12] = ["Undefined", "Stopped", "Paused", "Playing", "ScanForward", "ScanReverse", "Buffering", "Waiting", "MediaEnded", "Transitioning", "Ready", "Reconnecting"] GUISetState(@SW_SHOW) ;;Sleep(100);; to eliminate initial Kiosk mode and Transparent screen flicker WinMove($mainGUI, "", (@DesktopWidth - $width) / 2, (@DesktopHeight - $height) / 2) Local $isVisible = 1 FileDelete($swfFilename) FileDelete($keyFile) #endregion ;; ...main GUI "idle around loop" While 1 Sleep(100) WEnd _Exit();; unreachable ;;----------------- Flash/IE event receiver Func IeEvent_onpropertychange() Local $event = @COM_EventObj If Not $movie Then $movie = _IEGetObjById ($ieOBJ, "gsbMovie") If IsObj($event.bridge) Then If $event.bridge.cmd = "initialize" Then $movie.SetVariable ("/:au3Init", $event.bridge.args) ElseIf $event.bridge.cmd = "loaded" Then AdlibDisable();; kill load timeout Else $movie.gsbTrace ("AU3: " & $event.bridge.cmd & ", " & $event.bridge.args & " [" & $event.bridge.cb & "]") gsbCommands($event.bridge.cmd, $event.bridge.args, $event.bridge.cb) EndIf $event.bridge = "" Local $rv = $movie.au3NextEvent ("") EndIf EndFunc ;==>IeEvent_onpropertychange ;;----------------- gsbCommand processor Func gsbCommands($cmd, $args, $cb) Select Case $cmd = "_About" _About($args) Case $cmd = "quit" _Exit() Case $cmd = "_Exit" _Exit() Case $cmd = "_ToggleVisibility" _ToggleVisibility() Case $cmd = "_Alert" _Alert($args) Case $cmd = "_StartWinDrag" Opt("MouseCoordMode", 0) $mousePos = MouseGetPos() Opt("MouseCoordMode", 1) GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "_WinDrag") Case $cmd = "_StopWinDrag" GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "") Case $cmd = "_ContextMenu" _Trace("_ContextMenu"); Case $cmd = "WMPlayer" ;; args - WMPlayerCommand, data [, more CSVs] Local $a = StringSplit($args, ",") Switch StringStripWS($a[1], 3) Case "open" If $a[0] > 1 Then Local $WMStream = StringStripWS($a[2], 3) $WMStation = $WMPlayer.newMedia ($WMStream) $WMPlayer.url = $WMStream While $WMStates[$WMPlayer.playState () ] <> "Playing" Sleep(100) $movie.WMDisplayState ($WMStates[$WMPlayer.playState () ]) WEnd $WMPlayer.settings.volume = $WMVol EndIf Case "mute" $WMVol = $WMPlayer.settings.volume $WMPlayer.settings.volume = 0 $movie.WMDisplayState ($WMStates[$WMPlayer.playState () ] & " :: Muted") Case "unmute" $WMPlayer.settings.volume = $WMVol $movie.WMDisplayState ($WMStates[$WMPlayer.playState () ]) Case Else _Trace("Bad WMPlayer Command: " & $a[1]) EndSwitch Case Else $movie.gsbTrace ("Unknown cmd: " & $cmd & " Args: [" & $args & "]") EndSelect EndFunc ;==>gsbCommands #region ;;----------------- Functions Func _LoadAbort() _Alert("SWF Load failure. Aborting. " & @LF); _Trace("*** Load Aborted.") _Exit() EndFunc ;==>_LoadAbort Func _WinDrag() Local $x, $y, $pos = MouseGetPos() Local $winPos = WinGetPos($mainGUI) If $pos[0] - $mousePos[0] < 0 Then $x = 0 ElseIf $winPos[2] - $mousePos[0] + $pos[0] > @DesktopWidth Then $x = @DesktopWidth - $winPos[2] Else $x = $pos[0] - $mousePos[0] EndIf If $pos[1] - $mousePos[1] < 0 Then $y = 0 ElseIf $winPos[3] - $mousePos[1] + $pos[1] > @DesktopHeight Then $y = @DesktopHeight - $winPos[3] Else $y = $pos[1] - $mousePos[1] EndIf WinMove($mainGUI, '', $x, $y) EndFunc ;==>_WinDrag Func _ToggleVisibility() If Not $isVisible Then GUISetState(@SW_SHOW) $isVisible = 1 Else GUISetState(@SW_HIDE) $isVisible = 0 MsgBox(266288, "Remember:",@LF&"<ESC> to exit"&@LF&"<CTL><SHIFT>V to 'Show' "&@LF&@LF, 10) EndIf EndFunc ;==>_ToggleVisibility Func _Trace($str) $movie.gsbTrace ($str) EndFunc ;==>_Trace Func _About($str = "") If $str = "" Then MsgBox(266288, "About", $AboutText, 10); modal, top, info Else MsgBox(266288, "About", "swf: " & $str & @LF & "exe: " & $AboutText, 10); modal, top, info EndIf EndFunc ;==>_About Func _Alert($str) MsgBox(266288, "Alert", $str, 10); modal, top, info EndFunc ;==>_Alert Func _Exit() $WMPlayer.controls.stop () Exit EndFunc ;==>_Exit #endregion Let me know... gsb
  5. Thank you. But clock is just the tip of what can be done. gsb
  6. So... This took way too long but was fun and I learned some. Thanks to Dale and lod3n for posted examples with hints. $js = ObjCreate("ScriptControl") $js.language = "Jscript" $sJS = "var gsMonthNames=new Array('January','February','March','April','May','June','July','August','September','October','November','December');" $sJS &= "var gsDayNames=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');" $sJS &= "Date.prototype.format=function(f){if(!this.valueOf())return ' ';var d=this;" $sJS &= "return f.replace(/(yyyy|mmmm|mmm|mm|dddd|ddd|dd|D|hh|nn|ss|a\/p)/gi,function($1){" $sJS &= "switch($1){" $sJS &= "case'yyyy':return d.getFullYear();" $sJS &= "case'mmmm':return gsMonthNames[d.getMonth()];" $sJS &= "case'mmm':return gsMonthNames[d.getMonth()].substr(0,3);" $sJS &= "case'mm':return (d.getMonth()+1).toString().fill();" $sJS &= "case'dddd':return gsDayNames[d.getDay()];" $sJS &= "case'ddd':return gsDayNames[d.getDay()].substr(0,3);" $sJS &= "case'dd':return d.getDate().toString().fill();" $sJS &= "case'D':return d.getDate().toString();" $sJS &= "case'hh':return ((h=d.getHours()%12)?h:12).fill();" $sJS &= "case'nn':return d.getMinutes().toString().fill();" $sJS &= "case'ss':return d.getSeconds().toString().fill();" $sJS &= "case'a/p':return d.getHours()<12?'a':'p';" $sJS &= "}});};String.prototype.fill=function(){return ('0'+this);};" $js.Eval( $sJS ) $sJS = "var Date1 = (new Date()).format('dddd, mmmm dd, yyyy');" $js.Eval( $sJS ) Local $Date1 = $js.Eval("Date1") ConsoleWrite(@LF & "Format1: " & $Date1 & @LF) $sJS = "var Date2 = (new Date()).format('mm/dd/yyyy');" $js.Eval( $sJS ) Local $Date2 = $js.Eval("Date2") ConsoleWrite("Format2: " & $Date2 & @LF) $sJS = "var Date3 = (new Date()).format('dddd, D of mmmm of yyyy');" $js.Eval( $sJS ) Local $Date3 = $js.Eval("Date3") ConsoleWrite("Format3: " & $Date3 & @LF & @LF) Maybe not quite all you want but it could be I think. It is a start but it is Sunday night and I must quit for a while. gsb
  7. This works great! Thanks again lod3n. I retro-fitted my flash application with this as my "standard." One comment though. As an event it is important to sequence the changes in javascript less you have data transfer collisions. This is a common problem in flash but others may be left scratching their heads. Nice, and thanks again. gsb
  8. Thanks again Dale for your response. In my case, calling AutoIt from Flash, the small event delay should never be an issue. Most communications with Flash are asynchronous anyway. Here, I can have synchronous communications with javascript, a built-in event delay and then synchronous communications back with Flash from the AutoIt script. By synchronous here I mean direct function calls with return values. Given that Flash movie's have a central "heartbeat" I do not expect this to even be noticed. But when I get some time I will perform some timing test. As far as generalization, I agree with your comment"...I'm not keen on enforcing a specific document namespace, so I'd like to find a more flexible implementation before doing more with it." I totally agree, but in this one use I find it workable. I was hoping someone would find a way to enable direct calls to the AutoIt script from the Flash object using it's "ExternalInterface" as using that to expose a Flash function AutoIt can directly call Flash. ...just not the other way around yet; Flash calling an AutoIt function or even a javascript function. Thanks for your time and response. gsb
  9. Actually lod3n. For that all you would need is a ObjCreate("ShockwaveFlash.ShockwaveFlash.1") control to load you swf into instead of the whole browser thing I am using. Remember, the IE setup is solely for the "visual" side of the control and it's bad behavior in an AutoIt GUI. gsb
  10. Thanks Dale. This seems to work. Local $flash, $oElement = @COM_EventObj If IsObj($oElement.param) Then $flash = $oElement.param.obj ;; $flash.SetVariable ("/:myFlashVariable", "some au3 string") << mimick this _SomeFunc( "SetVariable", "some au3 string") EndIf Func _SomeFunc( $funcRefString, $data ) { ... rv = Execute( "$flash." & $funcRefString & "('/:myFlashVariable','" & $data & "')" ); EndFunc This allows me to execute an exposed Flash function from within AutoIt. In this case, it is simply setting a variables value. The problem of getting the data back to Flash is solved. Thanks again for your help. gsb
  11. Thank you Dale. But I thought I had tried that with some return arguments and found no success. I must have mistyped it and will try again. How about another way: Func _SomeFunc( $funcRef, $moreArguments ) { ... $funcRef("some results") EndFunc This would too solve my problem if there is some way to pass the function reference as an argument. Thanks for your time. I will go back and see why my Execute test failed. BTW: Any comments on efficiency and adding such into IE.au3... as you mentioned above? gsb
  12. Thanks lod3n and no, I have not found it inefficient. Frankly, I am not sure how I would measure such at this point. It is just that I was thinking about generalizing it some for my flash interface (BTW: http://www.autoitscript.com/forum/index.ph...t&p=362234) where it would be more extensively used. So was wondering since it is: Flash ==> javascript ==> DOM ==> [event] ==> AutoIt ==> Flash Seemed like a bit of a trip and was wondering how extensively it could be used w/o issue. On a related subject is the final step: a callback to Flash. This is doable based on the object passed via IE's _onpropertychange event: Local $oElement = @COM_EventObj If IsObj($oElement.param) Then $flash = $oElement.param.obj $flash.SetVariable ("/:myFlashVariable", "some au3 string") EndIfThis works fine. Here the exposed function 'SetVariable' is hard-coded. I would like to make the exposed function variable, say the text string "SetVariable" but have had no luck in AutoIt. Do you know of any way to do that in AutoIt? ...something like: $flash["SetVariable"] ("/:myFlashVariable", "some au3 string") Simple enough in other languages but an AutoIt solution eludes me yet. gsb
  13. This is quite useful to me. But "how efficient" is this approach? ...cpu resources, timing wise I mean. Any idea? gsb
  14. Thanks martin. I will add that as a prerequisite to my original post. But an AutoIt'er that does not use IE... Isn't that an oxymoron? ( I am new here and that is meant to be funny. ) So much of AutoIt seems designed for IE automation and not other browsers. As an add-in, how would I add to the script a check to see if the target machine has the Flash Player plugin for IE? I know I could do it in Javascript from within the browser, but anyway, say via AutoIt searching the registry? gsb
  15. Thanks RazerM. But smashly, it should dl the files for you. And I does require the Flash Player Plugin for IE to be on your machine. It is simply a transparent flash movie, swf. You too had trouble martin? Argh.... gsb
×
×
  • Create New...