You should know where you are drawing the button...
In your code, the location:
imagex, imagey
By default, images are drawn from the top-left corner, though you can change this if required with either HandleImage or MidHandle.
you know the width and height of your button:
imagew = ImageWidth(buttonimg)
imageh = ImageHeight(buttonimg)
So, all you need is to check the mouse position ( MouseX() and MouseY() ) when the left-mouse-button is clicked. ( Mousedown(True) )
;Default: Button not highlighted
HighlightOn=False
;see if the cursor is within the on-screen button's area
If ( ((MouseX()) <= (imagex + imagew))
And (MouseX())>=(imagex))
And ((MouseY()) <= (imagey+imageh))
And (MouseY())>=(imagey))
)
; MouseOver - Draw Highlight rectangle around Button (Thickness= 10 )
HighlightOn=True
For iterhighlight =1 To 10
Rect imagex-iterhighlight,imagey-iterhighlight,imagew+(2*iterhighlight),imageh+(2*iterhighlight)
Next
Else
;Reset the Highlight, just in case.
HighlightOn=False
End If
;See if the mousebutton is clicked
If (MouseDown(True)And(HighlightOn))
;Do WhateverHappens when Button is clicked
DoButtonClick()
EndIf