Jump to content
Macro Express Forums

Detecting colour of progress bar?

Recommended Posts

I'm trying to detect when a blue progress bar moving rightwards reaches a certain point on its grey backround, and I'm puzzled why it fails. It looks like this:


Repeat Until %PixelCol% Equals "10382418" // Blue, implying progress bar nearing end

Get Pixel Color at (1881, 1164) Relative to Screen into %PixelCol%

Delay: 5 seconds

End Repeat



(And variations, including an IF test.)


It sails cheerfully past the set location without finishing the repeat loop.


I'll try other programs and progress bars, but meanwhile does anyone have any thoughts on possible causes for the failure please? Could it be that colour detection needs a perfectly static image?



Terry, East Grinstead, UK

Link to comment
Share on other sites

Using DOpus I started a 4Gb copy from one drive to another. This game me time to develop the macro and then run it. It worked perfectly!


Here's my code:

<REPEAT UNTIL Variable="%nPixelCol%" Condition="\x00" Value="6956042"/>
<GET PIXEL COLOR Option="\x01" Rel_To_Screen="TRUE" X="580" Y="425" Destination="%nPixelCol%"/>
<DELAY Flags="\x01" Time="5"/>
<TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang3081{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Should be 6956042\r\n\\par PixelCol = %nPixelCol%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>


I presume you haven't fallen into the trap your code might imply? Your 1st mention of %PixelCol% will cause MEP to assign a text variable because there's nothing in the Repeat command to indicate what type of variable should be assigned. Mind you, if that did occur I wouldn't expect the Get Pixel Color command to compile.


Ah, wait a minute. If your %PixelCol% variable is indeed a text variable and you haven't attempted to save this macro (syntax error message is generated), then you won't see the error message. And running it does indeed produce the behaviour you describe.


BTW, does your wave file play? If so, then my syntax error message diagnosis is wrong, since the macro continued running. But I'm almost prepared to lay odds that it didn't! There's confidence for you!

Link to comment
Share on other sites

A couple more ideas, in case Paul didn't nail it:


(1) Should you be getting pixel color relative to WINDOW or relative to SCREEN?


(2) Instead of relying on an absolute color value, do an initial capture of pixel color, save it as both original color and current color, then "repeat until current color is NOT equal to original color". The trouble with specifying an exact color value is, the color may change on a different PC or if you switch among 16 / 24 / 32 bit color schemes.


(3) Move the mouse pointer to the pixel location, as a debugging tool to make sure the macro is checking the right location.


P.S. Maybe ME doesn't like your accent. Over here we always check colors, not colours> :P

Link to comment
Share on other sites

Thanks both.


I modified it for a simple copy file operation, and it worked fine. Note that the progress bar in an XP copy is 'incremental', not a smoothly continuous moving bar as in my original example. So the location tested is either grey (13160660) - that's gray, Bob - or navy blue (6956042), essentially a static scenario. That could be the reason. Or it could be that particular application (Magix Movie Edit Pro), which is 'non-standard' in several respects. I need to try with some other 'smooth' progress bar, ideally in an easily accessible application.



Terry, East Grinstead, UK

Link to comment
Share on other sites

Yes, I agree. In fact, what prompted my attempt to write this macro was that I was trying to find a way to help me record how long a project takes to render. It can be anything from under a minute to several hours and I'm testing various configurations. Disappointingly, MEP doesn't show a final render time, or apparently log it anywhere.


P.S: MEP, of course, means Movie Edit Pro - often a source of ambiguity on my own desktop ;)


Edit: Sorted. Magix Support emailed me an undocumented method of recording a log file, which explicitly includes Duration of the video and its Rendering time.


As for the failure of my macro: user error. I was testing with a very short file which rendered in about 30 seconds. So, with my target position at about 95%, that 5 second delay was far too long!



Terry, East Grinstead, UK

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...