Sign in to follow this  
Followers 0
Boss007

script to manipulate Koda document

7 posts in this topic

Hi I am A total novice. I need to preform an action based on gender. I used koda to draw a box displaying a choose gender window with three buttons, select gender,Male,Female. I now want to run one of two actions dependant on the gender chosen... " if button 1 is selected then do this, if button 2 is selected then viper gender select.au3do that" here is my coding imported into Au3. I'm Lost any help would be appriciated thanks!

#include <ButtonConstants.au3>

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=gender select.kxf

$Form2 = GUICreate("Select your Gender", 279, 213, 468, 254)

$GroupBox1 = GUICtrlCreateGroup("", 48, 33, 185, 129)

GUICtrlSetBkColor(-1, 0x008080)

GUICtrlCreateGroup("", -99, -99, 1, 1)

$Button1 = GUICtrlCreateButton("Male", 54, 107, 75, 25)

GUICtrlSetBkColor(-1, 0x0054E3)

$Button2 = GUICtrlCreateButton("Female", 149, 108, 75, 25)

GUICtrlSetBkColor(-1, 0xFF00FF)

$Button3 = GUICtrlCreateButton("Select Your Gender", 85, 52, 115, 25)

GUICtrlSetBkColor(-1, 0x00FF00)

GUISetState(@SW_SHOW)

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

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

well this will make your gui work. i dont really see the point of making the select gender a button

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=gender select.kxf
$Form2 = GUICreate("Select your Gender", 279, 213, 468, 254)
$GroupBox1 = GUICtrlCreateGroup("", 48, 33, 185, 129)
GUICtrlSetBkColor(-1, 0x008080)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("Male", 54, 107, 75, 25)
GUICtrlSetBkColor(-1, 0x0054E3)
$Button2 = GUICtrlCreateButton("Female", 149, 108, 75, 25)
GUICtrlSetBkColor(-1, 0xFF00FF)
$Button3 = GUICtrlCreateButton("Select Your Gender", 85, 52, 115, 25)
GUICtrlSetBkColor(-1, 0x00FF00)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
   $msg = GUIGetMsg()

   Switch $msg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_maleFunction()
Case $Button2
_femaleFunction()
   EndSwitch
WEnd

Func _maleFunction()
   ;insert code here
EndFunc

Func _femaleFunction()
   ;insert code here
EndFunc
Edited by pieeater
1 person likes this

[spoiler]My UDFs: Login UDF[/spoiler]

Share this post


Link to post
Share on other sites

Button3 have no sense as button it should be just label

$label1 = GUICtrlCreateLabel("Select Your Gender", 85, 60, 115, 15, BitOr($GUI_SS_DEFAULT_LABEL, $SS_CENTER))
GUICtrlSetBkColor(-1, 0x00FF00)

Share this post


Link to post
Share on other sites

Another way is to use Radio buttons

#include <ButtonConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=gender select.kxf
$Form2 = GUICreate("Select your Gender", 279, 213, 468, 254)
$GroupBox1 = GUICtrlCreateGroup("", 48, 33, 185, 129)
GUICtrlSetBkColor(-1, 0x008080)
$cbx_male = GUICtrlCreateRadio("Male", 54, 107, 75, 25)
GUICtrlSetBkColor(-1, 0x0054E3)
$cbx_female = GUICtrlCreateRadio("Female", 149, 108, 75, 25)
GUICtrlSetBkColor(-1, 0xFF00FF)
$Button1 = GUICtrlCreateButton("Select Your Gender", 85, 52, 115, 25)
GUICtrlSetBkColor(-1, 0x00FF00)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        Exit

        Case $Button1
            SelectGender()

    EndSwitch
WEnd

Func SelectGender()
    If IsChecked($cbx_male) Then
        ; insert code here for male
    ElseIf IsChecked($cbx_female) Then
        ; insert code here for female
    Else
        MsgBox(48,'Warning','Male or Female must be selected!')
    EndIf
EndFunc

Func IsChecked($control)
    Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED
EndFunc

Share this post


Link to post
Share on other sites

well this will make your gui work. i dont really see the point of making the select gender a button

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=gender select.kxf
$Form2 = GUICreate("Select your Gender", 279, 213, 468, 254)
$GroupBox1 = GUICtrlCreateGroup("", 48, 33, 185, 129)
GUICtrlSetBkColor(-1, 0x008080)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("Male", 54, 107, 75, 25)
GUICtrlSetBkColor(-1, 0x0054E3)
$Button2 = GUICtrlCreateButton("Female", 149, 108, 75, 25)
GUICtrlSetBkColor(-1, 0xFF00FF)
$Button3 = GUICtrlCreateButton("Select Your Gender", 85, 52, 115, 25)
GUICtrlSetBkColor(-1, 0x00FF00)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
   $msg = GUIGetMsg()

   Switch $msg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_maleFunction()
Case $Button2
_femaleFunction()
   EndSwitch
WEnd

Func _maleFunction()
   ;insert code here
EndFunc

Func _femaleFunction()
   ;insert code here
EndFunc

Thanks your absolutly correct I have adjusted the coding to reflect this.when I first used koda I had no idea of what I was doing,and used the coding generated by koda.Thanks for the selection routine.and the links aswell your a diamond!

Share this post


Link to post
Share on other sites

Button3 have no sense as button it should be just label

$label1 = GUICtrlCreateLabel("Select Your Gender", 85, 60, 115, 15, BitOr($GUI_SS_DEFAULT_LABEL, $SS_CENTER))
GUICtrlSetBkColor(-1, 0x00FF00)

Yes your correct newbie error. thanks for the code!

Share this post


Link to post
Share on other sites

Another way is to use Radio buttons

#include <ButtonConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=gender select.kxf
$Form2 = GUICreate("Select your Gender", 279, 213, 468, 254)
$GroupBox1 = GUICtrlCreateGroup("", 48, 33, 185, 129)
GUICtrlSetBkColor(-1, 0x008080)
$cbx_male = GUICtrlCreateRadio("Male", 54, 107, 75, 25)
GUICtrlSetBkColor(-1, 0x0054E3)
$cbx_female = GUICtrlCreateRadio("Female", 149, 108, 75, 25)
GUICtrlSetBkColor(-1, 0xFF00FF)
$Button1 = GUICtrlCreateButton("Select Your Gender", 85, 52, 115, 25)
GUICtrlSetBkColor(-1, 0x00FF00)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        Exit

        Case $Button1
            SelectGender()

    EndSwitch
WEnd

Func SelectGender()
    If IsChecked($cbx_male) Then
        ; insert code here for male
    ElseIf IsChecked($cbx_female) Then
        ; insert code here for female
    Else
        MsgBox(48,'Warning','Male or Female must be selected!')
    EndIf
EndFunc

Func IsChecked($control)
    Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED
EndFunc

thanks this worked as well!

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