Jump to content

Problem with AnimateWindow


ESPUser
 Share

Recommended Posts

Hi,

i am working on a slideshow (yes, a screensaver).

Everything works fine, but i have a small cosmetic problem:

The fade out always looks buggy, hard to explain, i added some code to show what i mean.

Does anybody know what i am doing wrong here or if there are alternative ways to use transition animations for the images?

#include <GUIConstants.au3>
#include <WindowsConstants.au3>

$wait = 2000
$speed = 500
$effectin = 0x00040010
$effectout = 0x00050010

;balck background
$hBackgroundWindow = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW)
GUISetBkColor(0x000000, $hBackgroundWindow)
GUISetState(@SW_SHOW, $hBackgroundWindow)

$hGUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$picture = GUICtrlCreatePic(@WindowsDir & "\Web\Screen\img100.jpg", 0, 0, @DesktopWidth, @DesktopHeight)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW, $hGUI)

Opt("GuiOnEventMode", 1)
HotKeySet("{ESC}", "Close")
GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "Close")
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "Close")
While 1
    ;i would like to do a smooth fade out and fade in, but the fade out always starts with a "jump" an looks unsmooth
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hGUI, "int", $speed, "long", $effectout)
    GUICtrlSetImage($picture, @WindowsDir & "\Web\Screen\img100.jpg")
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hGUI, "int", $speed, "long", $effectin)
    Sleep($wait)
WEnd

Func Close()
    Opt("GuiOnEventMode", 0)
    HotKeySet("{ESC}")
    GUIDelete($hGUI)
    GUIDelete($hBackgroundWindow)
    Exit
EndFunc   ;==>Close

Thanks for your help!

Markus

Edited by ESPUser
Link to comment
Share on other sites

Before looking into the problem itself, some points: a screensaver might 'save' your computer activity. What your programm actually do is just looking like a screen saver. It idles nothing (or nearly nothing, maybe a bit of 3D acceleration but not that much because you display 2 windows on top of one eachother) and it 'stress' a lot your CPU, allocates roughly 100Mb RAM and uses some non negligable disk reading.

Don't saying that to be rude, only for your information :) But there's some way to do this 'correctly' ;) 

Gonna check why there is this 'jump' as you said, got some ideas, but don't have so much time to dig this atm.

Strength and Honor o/

Link to comment
Share on other sites

Thanks, i look forward for your ideas - the code is just the minimal code that shows the problem.

Two windows are in the code to make sure the background ist black on all monitors (using the complete canvas and not only @desktopheight/@desktopwidth, but not in this example) and the pictures are only displayed on the main monitor...

If you have better ideas, i am happy to improve my code.

I looked at many sample screensavers here in the forum and tried to pick the best parts and everythings works for me, but i am sure it can be improved a lot.

Link to comment
Share on other sites

Quote

It idles nothing...and it 'stress' a lot your CPU, allocates roughly 100Mb RAM and uses some non negligable disk reading.

I checked the performance in the Taskmanager and my ScreenSaver (more than the code above) uses about 8MB and 0,1% CPU and minimal disk access (loading the pictures).

I think this is OK, or did i miss something?

Link to comment
Share on other sites

 

Here are the results of my ScreenSaver, including the WindowAnimations

The spikes are from loading new pictures and animating them

I also tested the Microsoft Screensavers, all of them are between 1 and 5% CPU, so it seems OK to me that my SCR uses 1-5%

grafik.png.bf4b82ee86eea77cd8b75b19bec92cb0.png

Edited by ESPUser
Link to comment
Share on other sites

I reduced the code even more, but i still see this white flash between animations.

 

#include <WindowsConstants.au3>

$hGUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$picture = GUICtrlCreatePic(@WindowsDir & "\Web\Screen\img100.jpg", 0, 0, @DesktopWidth, @DesktopHeight)
GUISetState(@SW_SHOW, $hGUI)

HotKeySet("{ESC}", "Close")

$speed = 1000
$effectin = 0x00040010
$effectout = 0x00050010

While 1
    ;i would like to do a smooth fade out and fade in, but the fade out always starts with a "jump/blip" white like a flash
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hGUI, "int", $speed, "long", $effectout)
    GUICtrlSetImage($picture, @WindowsDir & "\Web\Screen\img100.jpg")
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hGUI, "int", $speed, "long", $effectin)
WEnd

Func Close()
    HotKeySet("{ESC}")
    GUIDelete($hGUI)
    Exit
EndFunc   ;==>Close

 

Link to comment
Share on other sites


I tried several other AnimateWindow examples from the forum and they all have the same effect (short white flash between Animations), so i believe it just is the way this function works - i will try to use a different method to fade from one image to the next

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...