Jump to content

I'm stuck with a script.


Recommended Posts

Hi,

I'm working on a script atm, and there's one thing that I need to do - but I can't think a way to do it, but I don't think it can't be done. So what I want to do is the following.

Let's say we have one box of a specific color, say brown (doesn't really matter) the size and the position of the box is random, it can differ a couple of pixels. So, inside the brown box, there are white boxes (random position and size, though always inside the brown box, the number of white boxes are also random). I need a way to find out how many white boxes that are inside the brown box. Of course the boxes are in the active window.

Of course I could just start checking each pixel of the screen... but that wouldn't be very effective would it? :)

I don't need any code just some ideas on how to make this work. Thanks a lot in advance!

Link to comment
Share on other sites

are the boxes gui elements, are they in apicture or what ?

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

are the boxes always detached or do they overlap ?

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

mayby i've got it baut it's real crazy !

you should write a cicle which pixel searches 2 pixels at a time so youll' start with 0,1 and then 2,3 and so on

if both are white then they are part of the box (the white one)

you add them in an array... the cicle runs til the image is finished

at the end the number of the second index of the array gives you the number of boxes

:)

EDIT: NO 2D ARRAY!!

Edited by torels

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

#include <array.au3>
$pw = "picturewidth"
$y = 0
dim $h[1]
for $i = 0 to $pw Step +2
    if $i = $pw then $y += 1
    $p1 = PixelGetColor($i,$y)
    $p2 = PixelGetColor($i + 1,$y)
    
    if $p1 = Dec("FFFFFF") and $p2 = Dec("FFFFFF") Then $h[0] = "t"
    if $p1 = Dec("FFFFFF") and $p2 <> Dec("FFFFFF") Then _ArrayAdd($h,"")
    if $p1 <> Dec("FFFFFF") and $p2 = Dec("FFFFFF") then $h[ubound($h) - 1] = "t"
    
    if $i >= $pw then exitloop
Next

return (UBound($h) - 1) / $pw

should work!

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...