Sign in to follow this  
Followers 0
phil11

Button click

5 posts in this topic

Hi everybody, happy new year to all of you

i just started with Autoit, have some knowleges in vba, and couldn't find some help about my prob. via "search"

so i create some buttons and labels with koda and want that wenn i click on Button1 that the Label2 changes its color or get hidden

here's a part of the script :

CODE
$Button1 = GUICtrlCreateButton("", 93, 15, 16, 16, 0)

GUICtrlSetBkColor(-1, 0x515251)

GUICtrlSetOnEvent(-1, "Button1Click")

GUICtrlSetCursor (-1, 3)

$Button2 = GUICtrlCreateButton("", 160, 15, 16, 16, $BS_DEFPUSHBUTTON)

GUICtrlSetBkColor(-1, 0x515251)

GUICtrlSetOnEvent(-1, "Button2Click")

GUICtrlSetCursor (-1, 3)

$Label1 = GUICtrlCreateLabel("Nav", 83, 54, 33, 24)

GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0x00FF00)

GUICtrlSetOnEvent(-1, "Button1Click")

$Label2 = GUICtrlCreateLabel("Nav", 83, 54, 33, 24)

GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0x00FF00)

GUICtrlSetOnEvent(-1, "Button2Click")

#EndRegion ### END Koda GUI section ###

Func Button1Click()

If "Button1Click" = True Then

$Label2 = GUICtrlSetColor(-1, 0x00FFFF)

$Label3 = GUICtrlSetState(1, $GUI_HIDE)

EndIf

EndFunc

Thanks for some help

Phil

Share this post


Link to post
Share on other sites



thank you

i tried it compiled too, ... doesn't work

thanks for help

Share this post


Link to post
Share on other sites

I don't know what exactly do you want but here is some functional code.

Note: You posted only code snippet and not whole reproduccing script. In future post whole reproduccing script to get more help.

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

GUICreate("My GUI",300,200,-1,-1,BitOr($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX)) 
GUISetOnEvent($GUI_EVENT_CLOSE, "OnClose")

$Button1 = GUICtrlCreateButton("", 93, 15, 16, 16, 0)
GUICtrlSetBkColor(-1, 0x515251)
GUICtrlSetOnEvent(-1, "Buttonclick")
GUICtrlSetCursor(-1, 3)

$Button2 = GUICtrlCreateButton("", 160, 15, 16, 16, $BS_DEFPUSHBUTTON)
GUICtrlSetBkColor(-1, 0x515251)
GUICtrlSetOnEvent(-1, "Buttonclick")
GUICtrlSetCursor(-1, 3)

$Label1 = GUICtrlCreateLabel("Nav1", 83, 54, 33, 24)
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetOnEvent(-1, "Buttonclick")

$Label2 = GUICtrlCreateLabel("Nav2", 150, 54, 33, 24)
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetOnEvent(-1, "Buttonclick")

GUISetState (@SW_SHOW) 

While 1
    Sleep(100)
WEnd

Func OnClose()
    Exit
EndFunc

Func Buttonclick()
    GUICtrlSetState(@GUI_CtrlId, $GUI_HIDE) ; hide clicked button
        If @GUI_CtrlId = $Button1 Then
        GUICtrlSetColor($Label1, 0x00FFFF)
    EndIf
    If @GUI_CtrlId = $Button2 Then
        GUICtrlSetColor($Label2, 0x00FFFF)
    EndIf
EndFunc   ;==>Button1Click

Share this post


Link to post
Share on other sites

thank you, it will be very helpfull

:)

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  
Followers 0