Sign in to follow this  
Followers 0
JellyFish666

Pixel Screen Saver

7 posts in this topic

Alright I doubt this will protect your screen and isn't really a screen saver, but it did entertain me for a bit.

#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
HotKeySet("{ESC}" , "_Exit") 
$Amount = -50
$GUI = GUICreate("", @DesktopWidth +50, @DesktopHeight +50, -1, -1, $WS_POPUP);, $WS_EX_TOPMOST)
GUISetBkColor(0x000000)
GUISetState()

While 1
    _Screen()
WEnd

Func _Screen()
    If $Amount = @DesktopWidth +50 Then
        $Amount = 0 
    Else
    $Random = Random(0x000000, 0xFFFFFF)
    $Amount = $Amount +1
    GUICtrlCreateGraphic($Amount , 0, 1, @DesktopHeight + 50)
    GUICtrlSetColor(-1, $Random)
    GUICtrlSetBkColor(-1, $Random)
EndIf
EndFunc

Func _Exit()
    Exit
EndFunc

Share this post


Link to post
Share on other sites



I used this as a template to make another program that should run a gradient across the screen. This is my code. When I run it it displays only a blue gradient. Originally The binary in declaring the global was not there but I put it there in an attempt to solve my problem.

include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
HotKeySet("{ESC}" , "_Exit")
Global $count = -50
Global $Random = Binary(0x000000)
$GUI = GUICreate("", @DesktopWidth +50, @DesktopHeight +50, -1, -1, $WS_POPUP);, $WS_EX_TOPMOST)
GUISetBkColor(0x000000)
GUISetState()

While 1
    $count = 0
    Do
        _Screen()
        Sleep(10)
        $count = $count +1
        $Random = $Random +1
    Until $count >= @DesktopWidth +50
    Sleep(1000)
    $count = 0
WEnd
Func _Screen()
    ToolTip($Random, 5,5)
;~     $Random = Random(0x000000, 0xFFFFFF)
    GUICtrlCreateGraphic($count , 0, 1, @DesktopHeight +50)
;~     GUICtrlSetColor(-1, $Random)
    GUICtrlSetBkColor(-1, $Random)
EndFunc
Func _Exit()
    Exit
EndFunc

Share this post


Link to post
Share on other sites

maybe you'll like this :) :

#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
HotKeySet("{ESC}" , "_Exit")
$divider = 2 ;you can change this value, it's the size of the square, min = 2, max = @DesktopWidth
$GUI = GUICreate("", @DesktopWidth , @DesktopHeight, 0, 0, $WS_POPUP);, $WS_EX_TOPMOST)
GUISetBkColor(0)
GUISetState()

While 1
    _Screen2()
    Sleep(10)
WEnd

func _Screen2()
    $Random_x = Random(0, @DesktopWidth/$divider, 1)
    $Random_y = Random(0, @DesktopHeight/$divider, 1)
    if PixelGetColor($Random_x*$divider+$divider/2, $Random_y*$divider+$divider/2) = 0 Then
        $Random = Random(0x000000, 0xFFFFFF)
        GUICtrlCreateGraphic($Random_x*$divider, $Random_y*$divider, $divider, $divider)
        GUICtrlSetBkColor(-1, $Random)
    EndIf
EndFunc

Func _Exit()
    Exit
EndFunc

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

maybe you'll like this :) :

oddly enough... thats interesting to me... lol Edited by UPSman2

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi JellyFish666,

I like the concept, but running your script leaves my CPU usage @ 80%+ and it also chews a lot of memory if you leave it running for any great length of time.

The memory use is because your creating a graphics control every loop and never deleting them. which means a memory blowout at some point.

The cpu usage there's no sleep in between creating the controls.

Here's something similar using gdiplus

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

Global $speed = 10 ; Bigger the number faster the lines are drawn and more cpu usage.
Global $hGUI, $hWnd, $hGraphic, $hPen, $vDir, $vCnt, $hDir, $hCnt, $iDir, $i

$hGUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
GUISetBkColor(0)
GUISetState()

_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hPen = _GDIPlus_PenCreate()

While Not _IsPressed("1B")
    Sleep(20)
    Do
        _GDIPlus_Line()
        $i += 1
    Until ($i = $speed)
    $i = 0
WEnd

_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()

Func _GDIPlus_Line()
    _GDIPlus_PenSetColor($hPen, StringReplace(Hex(Random(0x000000, 0xFFFFFF)), "00", "0xFF", 1))
    If $vCnt = @DesktopWidth + 1 Then $vDir = 1
    If $vCnt = -1 Then $vDir = 0
    If $hCnt = @DesktopHeight + 1 Then $hDir = 1
    If $hCnt = -1 Then $hDir = 0
    If $iDir = 0 Then
        _GDIPlus_GraphicsDrawLine($hGraphic, $vCnt, 0, $vCnt, @DesktopHeight, $hPen)
        If $vDir = 0 Then $vCnt += 1
        If $vDir = 1 Then $vCnt -= 1
        If $vCnt = @DesktopWidth + 1 Or $vCnt = -1 Then $iDir = 1
    ElseIf $iDir = 1 Then
        _GDIPlus_GraphicsDrawLine($hGraphic, 0, $hCnt, @DesktopWidth , $hCnt, $hPen)
        If $hDir = 0 Then $hCnt += 1
        If $hDir = 1 Then $hCnt -= 1
        If $hCnt = @DesktopHeight + 1 Or $hCnt = -1 Then $iDir = 0
    EndIf
EndFunc   ;==>_GDIPlus_Line

Cheers

Edited by smashly

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hi JellyFish666,

I like the concept, but running your script leaves my CPU usage @ 80%+ and it also chews a lot of memory if you leave it running for any great length of time.

The memory use is because your creating a graphics control every loop and never deleting them. which means a memory blowout at some point.

The cpu usage there's no sleep in between creating the controls.

Here's something similar using gdiplus

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

Global $speed = 10 ; Bigger the number faster the lines are drawn and more cpu usage.
Global $hGUI, $hWnd, $hGraphic, $hPen, $vDir, $vCnt, $hDir, $hCnt, $iDir, $i

$hGUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
GUISetBkColor(0)
GUISetState()

_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hPen = _GDIPlus_PenCreate()

While Not _IsPressed("1B")
    Sleep(20)
    Do
        _GDIPlus_Line()
        $i += 1
    Until ($i = $speed)
    $i = 0
WEnd

_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()

Func _GDIPlus_Line()
    _GDIPlus_PenSetColor($hPen, StringReplace(Hex(Random(0x000000, 0xFFFFFF)), "00", "0xFF", 1))
    If $vCnt = @DesktopWidth + 1 Then $vDir = 1
    If $vCnt = -1 Then $vDir = 0
    If $hCnt = @DesktopHeight + 1 Then $hDir = 1
    If $hCnt = -1 Then $hDir = 0
    If $iDir = 0 Then
        _GDIPlus_GraphicsDrawLine($hGraphic, $vCnt, 0, $vCnt, @DesktopHeight, $hPen)
        If $vDir = 0 Then $vCnt += 1
        If $vDir = 1 Then $vCnt -= 1
        If $vCnt = @DesktopWidth + 1 Or $vCnt = -1 Then $iDir = 1
    ElseIf $iDir = 1 Then
        _GDIPlus_GraphicsDrawLine($hGraphic, 0, $hCnt, @DesktopWidth , $hCnt, $hPen)
        If $hDir = 0 Then $hCnt += 1
        If $hDir = 1 Then $hCnt -= 1
        If $hCnt = @DesktopHeight + 1 Or $hCnt = -1 Then $iDir = 0
    EndIf
EndFunc   ;==>_GDIPlus_LineoÝ÷ Ø(^z»?ªê-{
0¶­±ìZrÙr­"y¢æî¶
-nÞu·jëܲÚ,ØhºHw°)¶Á«'ßÛmæÞ²Üʦlº·¦k&ÞÝý²;¬¶Ø^Á¬²¢ébëhr^¢¹É·º{.­ê­¶¬v¬nëZ­é÷öÛazǬ¶¬jgºÚ"µÍ[[
    ÌÍÚHH    ÌÍÜÜYY
oÝ÷ Ù«­¢+ÙU¹Ñ¥°ÀÌØí¤ôÀÌØíÍÁ
Edited by JellyFish666

Share this post


Link to post
Share on other sites

Yep they're the same, just a pointless intermittent habit, be it bad or good I'm not sure :P

But it does no harm :)

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