ESPUser Posted August 15, 2021 Posted August 15, 2021 (edited) 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? expandcollapse popup#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 August 15, 2021 by ESPUser
636C65616E Posted August 15, 2021 Posted August 15, 2021 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/
ESPUser Posted August 15, 2021 Author Posted August 15, 2021 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.
ESPUser Posted August 16, 2021 Author Posted August 16, 2021 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?
ESPUser Posted August 16, 2021 Author Posted August 16, 2021 (edited) 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% Edited August 16, 2021 by ESPUser
636C65616E Posted August 16, 2021 Posted August 16, 2021 well, maybe for some obscure reasons it doesn't really work on my computer
ESPUser Posted August 16, 2021 Author Posted August 16, 2021 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
ESPUser Posted August 16, 2021 Author Posted August 16, 2021 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now