Pathologic

Pixelsearch within while loop for progress bar?

4 posts in this topic

#1 ·  Posted

I want to create a much larger status bar that tracks the progress of a very small status bar in an application so that I can see it from far away. I cannot for the life of me work out why this isn't working, I must be missing something obvious. 

 

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#include <Math.au3>
$pix = 0
$pixel = 0
$progress = 100
$state = ""

GUICreate("bar", 300, 30, 810, 715,$WS_POPUP+$WS_DISABLED+$GUI_NOFOCUS,$WS_EX_TOPMOST)
               GUISetState(@SW_SHOWNOACTIVATE)
               Local $idProgressbar1 = GUICtrlCreateProgress(0, 0, 300, 30)
               GUICtrlSetColor(-1, 32250)

While 1
  $pixel = PixelSearch(1724,601,1607,602,0xFFFFFF,0,1)
    if not @error then
        $pix = $pixel[0] - 1607
        $progress = Round(($pix/117)*100-1,0)
        $state = ""
     Else
        $state = "ERROR"
   EndIf
        GUICtrlSetData($idProgressbar1, $progress)
Tooltip($state & $pixel[0] & " - " & $pix & " - " & $progress,1920,500)
Sleep(100)
WEnd

Basically, there is a white progress bar stretching from ~1607,600 to ~1724,605. I am trying to pixelsearch for the right-most pixel in the range specified that remains white, work out what percentage of the bar remains, and translate that into a new progress bar. 

If I comment out the pixelsearch stuff and set the $progress variable with a straight counter ($pixel = $pixel+1 or -1), the progress bar moves just fine, meaning the while loop is looping and the progress bar functions fine. If I start the script with the tooltip in place it shows correct initial numbers (the first pixel found is at 1724, the bar is 117 pixels long which is 100% of the bar). 

However, then nothing happens. The tooltip never updates again, it doesn't show me that it errored, it doesn't do anything at all. 

 

Am I missing something obvious? I really hope so :s Even if the pixelsearch is wrong somehow, why is it not progressing to the @error tooltip?

Share this post


Link to post
Share on other sites



#2 ·  Posted

@Pathologic sounds like a great Rube Goldberg script you got going there. If you already have a status bar and it is simply too small to see, have you looked into magnifying a portion of your screen?  As you can see, it has been discussed a lot:


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted

There is an UDF available for a custom progress bar.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

On 6/19/2017 at 10:16 PM, JLogan3o13 said:

@Pathologic sounds like a great Rube Goldberg script you got going there. If you already have a status bar and it is simply too small to see, have you looked into magnifying a portion of your screen?  As you can see, it has been discussed a lot:

It seems to me that magnifying a section of the screen might be more resource-intensive than pixelsearching an area and creating a progress bar from that information? Maybe I'm wrong though, Ill look into it. Thanks. 

 

On 6/19/2017 at 10:26 PM, water said:

There is an UDF available for a custom progress bar.

I'll give it a go, thanks.

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