Jump to content
Sign in to follow this  
LithiumLi

Detection GUI

Recommended Posts

LithiumLi

Hello

I have a GUI with two shapes and when those shapes touch I want it to do a function although I don't want to have it detecting it by using positions if possible since these objects will be moving randomly.

I would also like it to not flicker while moving.

HotKeySet("{RIGHT}" , "_Move")
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

GUICreate("Test", 300, 100)
$Graphic1 = GUICtrlCreateGraphic(0, 0, 100, 100)
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, 0x00FF00)
$Graphic2 = GUICtrlCreateGraphic(200, 0, 100, 100)
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetBkColor(-1, 0xFF0000)
GUISetState(@SW_SHOW)
$Move = 0 
While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func _Move()
    $Move = $Move +10
    GUICtrlSetPos($Graphic1 , $Move , Default)
EndFunc
Edited by LithiumLi

Share this post


Link to post
Share on other sites
qazwsx

The only way i could think to do it without knowing the position is to use pixel functions to see when they over lap, but that seems like a terrible idea. If you are moving them, then you know the position.

Share this post


Link to post
Share on other sites
LithiumLi

The only way i could think to do it without knowing the position is to use pixel functions to see when they over lap, but that seems like a terrible idea. If you are moving them, then you know the position.

I guess I can read my random return value and just add/subtract seems like best method.

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
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.