Jump to content

Creating a Flash Desktop


 Share

Recommended Posts

Hello

I'm trying to make program that will work like windows desktop but for background image and buttons to use an .swf (Adobe Flash) file.

Program works fine with buttons and background but it's nor really working like windows desktop do.

If I dont DISABLE the main GUI it works fine (buttons,effects and e.t.c) but when I click at background (click at shockwave object) the GUI window comes at the top of all other windows.

If I make main GUI DISABLE then it works like windows desktop (my program doesnt come at the top of all others) but buttons and flash effects not working at all.

Please I will appreciate any help about this problem I have.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $FlashFile = @ScriptDir & "\test.swf"

Dim $oSW = ObjCreate('ShockwaveFlash.ShockwaveFlash.1')
ObjEvent($oSW, 'Shockwave_')

Dim $hGUI = GUICreate("MainGUI", @DesktopWidth, @DesktopHeight - 20,0,0,$WS_POPUP, WinGetHandle("[CLASS:Progman]"))
;GUISetState(@SW_DISABLE,$hGUI)
Dim $Shockwave = GUICtrlCreateObj($oSW, 0, 0, @DesktopWidth, @DesktopHeight - 20)

$swfObjEvents = ObjEvent($oSW,"FSCommand")
GUISetState()

With $oSW
    $oSW.LoadMovie(0,$FlashFile)
    $oSW.Play
EndWith

While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd

Func FSCommand($type,$command,$arguments)
    If $type = "FSCommand" Then
        If $command <> "fullscreen" AND $command <> "allowscale" AND $command <> "showmenu" Then Run($arguments)
    EndIf
EndFunc

Here are .au3 anf .swf files

FlashDesktop.rar

Link to comment
Share on other sites

Mat , I search more about the _WinAPI_SetWindowPos and you was right.

The problem I had was solved and here is the new-fixed code

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#Include <WinAPI.au3>

Global $FlashFile = @ScriptDir & "\test.swf"

Dim $oSW = ObjCreate('ShockwaveFlash.ShockwaveFlash.1')
ObjEvent($oSW, 'Shockwave_')

Dim $hGUI = GUICreate("MainGUI", @DesktopWidth, @DesktopHeight - 20,0,0,$WS_POPUP,-1, WinGetHandle("[CLASS:Progman]"))
;GUISetState(@SW_DISABLE,$hGUI)
Dim $Shockwave = GUICtrlCreateObj($oSW, 0, 0, @DesktopWidth, @DesktopHeight - 20)

$swfObjEvents = ObjEvent($oSW,"FSCommand")
GUISetState()

With $oSW
    $oSW.LoadMovie(0,$FlashFile)
    $oSW.Play
EndWith

While 1
    _WinAPI_SetWindowPos($hGUI, $HWND_BOTTOM, 0, 0, 0, 0, BitOR($SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE))
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd

Func FSCommand($type,$command,$arguments)
    If $type = "FSCommand" Then
        If $command <> "fullscreen" AND $command <> "allowscale" AND $command <> "showmenu" Then Run($arguments)
    EndIf
EndFunc

but now I have a new problem.

When I change from Active window to another window or when I click at desktop background, all windows flickering for less than a second but it not looks nice.

It seems like desktop program comes at the top and go again at the bottom from the _WinAPI_SetWindowPos command.

Can someone help with this?

Link to comment
Share on other sites

Still not perfect but a slight improvement...

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#Include <WinAPI.au3>

Global $FlashFile = @ScriptDir & "\test.swf"

Dim $oSW = ObjCreate('ShockwaveFlash.ShockwaveFlash.1')
ObjEvent($oSW, 'Shockwave_')

Dim $hGUI = GUICreate("MainGUI", 10, 10, -100, -100,$WS_POPUP,-1, WinGetHandle("[CLASS:Progman]"))
;GUISetState(@SW_DISABLE,$hGUI)
Dim $Shockwave = GUICtrlCreateObj($oSW, 0, 0, @DesktopWidth, @DesktopHeight - 20)

$swfObjEvents = ObjEvent($oSW,"FSCommand")
$cur = WinGetHandle ("[active]")
GUISetState()
_WinAPI_SetWindowPos($hGUI, $HWND_BOTTOM, 0, 0, @DesktopWidth, @DesktopHeight - 20, $SWP_NOACTIVATE)
WinActivate ($cur)

With $oSW
    $oSW.LoadMovie(0,$FlashFile)
    $oSW.Play
EndWith

While 1
    _WinAPI_SetWindowPos($hGUI, $HWND_BOTTOM, 0, 0, @DesktopWidth, @DesktopHeight - 20, BitOR($SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE))
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd

Func FSCommand($type,$command,$arguments)
    If $type = "FSCommand" Then
        If $command <> "fullscreen" AND $command <> "allowscale" AND $command <> "showmenu" Then Run($arguments)
    EndIf
EndFunc

Mat

Link to comment
Share on other sites

i've found a simpler way to do this without autoit at all (unless you want to use autoit to modify the html file to change the swf application and reset the background to something then back to the html file. javascript executed in the html file can read/write to the registry, start applications, and probably even use I/O resources)

this is a sample htm file (note, you should keep it as a .htm instead of .html):

you need only change the 'file' variable if you want a different swf, it can probably come from an internet resource too since i stuck the internet MOW up there (ensures installing IE7+ doesn't break your wallpaper); and to avoid the 'click to use this control' thing, it's written using the SWFObject from googlecode (externally linked)

<!-- saved from url=(0014)about:internet --><html><head><script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js" lanuage="javascript"></script>
<title>Lighting</title><style>* {margin:0;padding:0;position:fixed;top:0px;left:0px;}</style></head><body bgcolor="#000000"><p id="bg"></p><script Language="javascript">
var file = "Lighting\\asteroids.swf"
swfobject.embedSWF(file,"bg","100%","100%","9",false,{},{bgcolor:"#000000",allownetworking:"all",allowscriptaccess:"always",wmode:"opaque"},{});
</script></body></html>
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...