Sign in to follow this  
Followers 0
Cod3Monk3y

getting button click

12 posts in this topic

i have an "Ok" and "Cancel" button and can't figure out how to figure out when one is clicked? I'm sure there's an On_Button_1_Click event, but i'm not sure how to get it. I've looked through all kinds of things, but still can't seem to find an answer.

Thanks in advance

Share this post


Link to post
Share on other sites



See the "CodeWizard" under SciTE Tools

#Region --- CodeWizard generated code Start ---
;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes, No, and Cancel, Icon=None, Timeout=10 ss
If Not IsDeclared("iMsgBoxAnswer") Then Dim $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(3,"Message Box","Please respond",10)
Select
   Case $iMsgBoxAnswer = 6;Yes

   Case $iMsgBoxAnswer = 7;No

   Case $iMsgBoxAnswer = 2;Cancel

   Case $iMsgBoxAnswer = -1;Timeout

EndSelect
#EndRegion --- CodeWizard generated code End ---

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Valuater showed you the answer for a msgbox, here's another for a gui

#include <GuiConstants.au3>

GuiCreate("MyGUI", 392, 323)

$Button_1 = GuiCtrlCreateButton("OK", 90, 260, 80, 30)
$Button_2 = GuiCtrlCreateButton("Cancel", 230, 260, 80, 30)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_1
        MsgBox(0,"Button", "Ok selected")
    Case $msg = $Button_2
        MsgBox(0,"Button", "Cancel selected")
    EndSelect
WEnd
Exit

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Thanx for the quick responses, actually figured it out after i hit submit.

I do have another question.

Once I've gotten that the user hit the okay button how to I check to see which checkboxes and radio buttons are selected?

Share this post


Link to post
Share on other sites

straight from help

For Checkbox, Radio control several states can be returned as $GUI_FOCUS and $GUI_CHECKED,. So use i.e. BitAnd(GUICtrlRead($Item),$GUI_CHECKED) to test if the control is checked.

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

USE...

#include <GUIConstants.au3>
; == GUI generated with Koda ==
$Form1 = GUICreate("AForm1")
$ck1 = GUICtrlCreateCheckbox("Helper", 40, 56, 81, 85)
$btn = GUICtrlCreateButton( "test check box", 40, 156, 80, 35) 
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $btn
        If BitAnd(GUICtrlRead($ck1),$GUI_CHECKED) = $GUI_CHECKED then MsgBox(64, "Test", "Box is Checked", 5)
    Case Else
       ;;;;;;;
    EndSelect
WEnd
Exit

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Is there any way to do the same while using GUIOnEventMode ?

Share this post


Link to post
Share on other sites

Is there any way to do the same while using GUIOnEventMode ?

for the gui yes, look for GUICtrlSetOnEvent in the help file


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Gafrost: Is it possible to send parameters to (OnEvent)functions?

I think about something like:

....
GUICtrlSetOnEvent($but1, "button_select(1)")
...


Func button_select($btn)

if $btn = 1 then...

EndFunc

But my example does not work :P

Share this post


Link to post
Share on other sites

Does anybody else know if it's possible to do it?

Share this post


Link to post
Share on other sites

Does anybody else know if it's possible to do it?

This has been asked many times, and I believe the answer is no.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

OK, Then I have to find another way to do it...

Edited by Cyberworld

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