Sign in to follow this  
Followers 0
iamtheky

Increment a GDI progress bar

5 posts in this topic

Running this you can increment the progress bar my pressing the up arrow.

I would like to set this up in a fashion where I can increment $o and $Blocks from outside the While statement (from within a large series of installs is my endgame), any suggestions are welcome.

#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <Misc.au3>

$o = 1
$Blocks = 1
_bar ()

Func _bar ()
While 1


    $Top = @desktopheight - 81
    $Bottom = @Desktopheight
    $MAX = 50
    $each  = @DesktopWidth / $MAX

    For $i = $o to $Blocks
$Rcolor = random (0x000000 , 0xFFFFFF)
    For $x = $each * ($i - 1) To $each * $i
    For $y = $Top To $Bottom

    _PixelSetColor ($x , $y , $Rcolor)

    Next
    Next

        If $i = $Blocks AND $Blocks > 1 Then
        $i = $each * $o
        Endif


        If _ispressed (26) Then
        $o += 1
        $Blocks += 1
        Endif

        If $o > 50 Then
        $Blocks = 1
        $o = 1
        Endif

    Next
Wend

EndFunc


Func _PixelSetColor($XCoord, $YCoord, $Color)
    Local $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", 0)
    If Not IsArray($dc) Then Return -1
    DllCall("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $XCoord, "long", $YCoord, "long", _
            "0x" & StringRegExpReplace(hex($Color,6), "(..)(..)(..)", "\3\2\1")) ; Change to 0xBBGGRR hex colour format.
    DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "hwnd", $dc[0])
EndFunc ;==>_PixelSetColor

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You can use e.g. AdlibRegister() to do this.

Why you are drawing directly to the desktop instead to a window?

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

No reason. Any particulars why I should not be drawing directly on the desktop?

I am making slow progress with the Adlib, but it is proving a bit finicky.


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

No reason. Any particulars why I should not be drawing directly on the desktop?...

Yes, it will be erased automatically from time to time by OS! I would use instead a transparent, borderless window where I would draw in the progress bar.

But you decide...

Regarding Adlib(): Either you use it for drawing or for checking the keys. I would use it for drawing.

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thanks, I had only seen the clearing when a window is dragged or redrawn over the area so figured i was good to go for my needs (There is nothing along the bottom of the PE window). Are there other reasons it would clear that I have yet to encounter. Thanks for entertaining my GDI queries.

Progress,

in this example the adlib is working nicely, however during the SEND commands the drawing pauses. Is this to be expected, I dont envision using many send commands in my installs, but are there many others I can expect to pause the drawing.

I added the sendKeyDelay to emphasize the pause during the send.

#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <Misc.au3>

Opt("WinTitleMatchMode", 1)
Opt("SendKeyDelay" , 10)

$o = 1
$Blocks = 1

AdlibRegister ("_bar")


$pad = run ("notepad.exe c:\test1.txt")
tooltip ("i am one" , 0 , 0)
sleep(1000)
$o += 1
$Blocks += 1
send ("test1 test1 test1 test1 test1 test1 test1 test1 test1 test1 test1 test1 test1 test1 test1" & @CRLF)

tooltip ("i am two" , 0 , 0)
sleep(1000)
$o += 1
$Blocks += 1
send ("test2 test2 test2 test2 test2 test2 test2 test2 test2 test2 test2 test2 test2 test2 test2" & @CRLF)

tooltip ("i am three" , 0 , 0)
sleep(1000)
$o += 1
$Blocks += 1
send ("test3 test3 test3 test3 test3 test3 test3 test3 test3 test3 test3 test3 test3 test3 test3" & @CRLF)

tooltip ("i am four" , 0 , 0)
sleep(1000)
$o += 1
$Blocks += 1
send ("test4 test4 test4 test4 test4 test4 test4 test4 test4 test4 test4 test4 test4 test4 test4" & @CRLF)

tooltip ("i am five" , 0 , 0)
sleep(1000)
$o += 1
$Blocks += 1
send ("test5 test5 test5 test5 test5 test5 test5 test5 test5 test5 test5 test5 test5 test5 test5" & @CRLF)

tooltip ("i am six" , 0 , 0)
sleep(1000)
$o += 1
$Blocks += 1
send ("test6 test6 test6 test6 test6 test6 test6 test6 test6 test6 test6 test6 test6 test6 test6" & @CRLF)

tooltip ("i am seven" , 0 , 0)
sleep(1000)
$o += 1
$Blocks += 1
send ("test7 test7 test7 test7 test7 test7 test7 test7 test7 test7 test7 test7 test7 test7 test7" & @CRLF)



Func _bar ()



    $Top = @desktopheight - 81
    $Bottom = @Desktopheight
    $MAX = 50
    $each  = @DesktopWidth / $MAX

    For $i = $o to $Blocks
    $Rcolor = random (0x000000 , 0xFFFFFF)
    For $x = $each * ($i - 1) To $each * $i
    For $y = $Top To $Bottom

    _PixelSetColor ($x , $y , $Rcolor)

    Next
    Next

        If $i = $Blocks AND $Blocks > 1 Then
        $i = $each * $o
        Endif

        If _ispressed (26) Then
        $o += 1
        $Blocks += 1
        Endif

        If $o > 50 Then
        $Blocks = 1
        $o = 1
        Endif

    Next


EndFunc


Func _PixelSetColor($XCoord, $YCoord, $Color)
    Local $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", 0)
    If Not IsArray($dc) Then Return -1
    DllCall("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $XCoord, "long", $YCoord, "long", _
            "0x" & StringRegExpReplace(hex($Color,6), "(..)(..)(..)", "\3\2\1")) ; Change to 0xBBGGRR hex colour format.
    DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "hwnd", $dc[0])
EndFunc ;==>_PixelSetColor
Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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