Jump to content
Sign in to follow this  

find a colored box

Recommended Posts


Hi Everyone,

This is my 1st time posting on these forums, pls go easy on me.

I am addicted to programming, I enjoy it. I made my 1st piece of code and would like some help with it.

Here is my code, its messy i know. What i would like is for someone to help make me a better programmer by pointing out flaws and ways to make things cleaner.

I apologise if i have posted this in the wrong place. Thx

my code

;finding a bar top left bar position and pixel color then moving mouse to the location.

MsgBox(0,"Wingman", "first well just mouse over the bar we want the dimensions for")

$mouseposa = MouseGetPos()

MsgBox(0,"Wingman", "now we have our 1st mouse pos saved, your mouse coods to x= " & $mouseposa[0] & "y= " & $mouseposa[1])

$pixcol = PixelGetColor($mouseposa[0], $mouseposa[1])

MsgBox(0,"Wingman", "e now have a pixel color as a marker" & Hex($pixcol, 6))

MsgBox(0,"Wingman", "next we are gonna attempt to move the mouse pointer to the top of the bar until the pixel color changes")

;get top of box

$pixcolmark = $pixcol

$var = 1

While $pixcolmark = $pixcol

$var = $var + 1

MouseMove($mouseposa[0], $mouseposa[1]-$var, 0)

$pixcolmark = PixelGetColor($mouseposa[0], $mouseposa[1]-$var)


MouseMove($mouseposa[0], $mouseposa[1]-$var+1, 0)

MsgBox(0,"Wingman", "there we are at the top of the box")

$topbox = MouseGetPos()

;get top left of box

$pixcolmark = $pixcol

$var = 1

While $pixcolmark = $pixcol

$var = $var + 1

MouseMove($topbox[0]-$var, $topbox[1], 0)

$pixcolmark = PixelGetColor($topbox[0]-$var, $topbox[1])


MouseMove($topbox[0]-$var+1, $topbox[1], 0)

$topleftbox = MouseGetPos()

MsgBox(0,"Wingman", "there we are at the top left of the box and the mouse position is saved for the top left most point")

;get top right position of box

$pixcolmark = $pixcol

$var = 1

While $pixcolmark = $pixcol

$var = $var + 1

MouseMove($topbox[0]+$var, $topbox[1], 0)

$pixcolmark = PixelGetColor($topbox[0]+$var, $topbox[1])


MouseMove($topbox[0]+$var-1, $topbox[1], 0)

$toprightbox = MouseGetPos()

;get the distance of the bar in pixels and divide by 10%

$vardiv = $toprightbox[0]- ($topleftbox[0])

MsgBox(0,"Wingman", "the distance of the box is " & $vardiv & "divided by 10 = " & $vardiv/10)


;move mouse to topright and start assigning variables

Dim $boxarray[10][2]

MouseMove($toprightbox[0], $toprightbox[1], 0)

$guide = MouseGetPos()

Local $i

For $i = 1 to 10 Step 1

$boxarray[$i-1][0] = MouseGetPos(0)

$boxarray[$i-1][1] = MouseGetPos(1)

MsgBox(0,"Wingman", "array number " & $i-1 & " x coods = " & $boxarray[$i-1][0] & " y coods = " & $boxarray[$i-1][1])

MouseMove($guide[0]-$tenpercent, $guide[1], 0)

$guide = MouseGetPos()


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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.