Sign in to follow this  
Followers 0
tonyjh

radio buttons on a Macro

5 posts in this topic

Hi all..... I am a n00b to script language programming. I have done a lot of macro building and programming in Lotus, which was very versitile and easy, but limited to Lotus. So I have a good understanding of the logic and flo chart organization, but script is very foriegn to me. I have used the recorder to write and do the tasks, and am starting to understand that part of it. But the Macro organization and logic has really thrown me. The Koda form designer is a joy to work with, but I can't get it to do anything once I have coded it. Can anyone help me?

Here is what I have. I have written 3 programs to put 3 different persons initials into the notes memo of a software program I use at work. So, I devleoped a macro using Koda Form Designer with 3 radio buttons on it (one for each persons initials) and 2 buttons (one for "OK" and one for "Cancel"). I want the radio button selection to launch one of the 3 programs I wrote. Their names are "Zap TH.au3"; "Zap GH.au3" and "Zap RB.au3." Below is the code..... and I don't know what to do from here.

....................................................................................................

.........................................................

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=C:\Documents and Settings\CurrentUser\Desktop\Robots\AForm1.kxf

$AForm1 = GUICreate("Dialog", 278, 186, 439, 211)

GUISetIcon("D:09.ico")

$GroupBox1 = GUICtrlCreateGroup("", 8, 32, 161, 145)

$Radio1 = GUICtrlCreateRadio(" Tony", 32, 56, 113, 17)

GUICtrlSetFont(-1, 12, 800, 2, "Times New Roman")

GUICtrlSetColor(-1, 0x800000)

GUICtrlSetBkColor(-1, 0xA6CAF0)

$Radio2 = GUICtrlCreateRadio(" Greg", 32, 96, 113, 17)

GUICtrlSetFont(-1, 12, 800, 2, "Times New Roman")

GUICtrlSetColor(-1, 0x800000)

GUICtrlSetBkColor(-1, 0xA6CAF0)

$Radio3 = GUICtrlCreateRadio(" Randy", 32, 136, 113, 17)

GUICtrlSetFont(-1, 12, 800, 2, "Times New Roman")

GUICtrlSetColor(-1, 0x800000)

GUICtrlSetBkColor(-1, 0xA6CAF0)

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

$Button1 = GUICtrlCreateButton("&OK", 184, 40, 75, 25, 0)

$Button2 = GUICtrlCreateButton("&Cancel", 184, 72, 75, 25, 0)

$Label1 = GUICtrlCreateLabel("Choose Appraiser for New Zapp", 8, 8, 262, 26)

GUICtrlSetFont(-1, 14, 800, 2, "Times New Roman")

GUICtrlSetColor(-1, 0x800000)

GUICtrlSetBkColor(-1, 0xA6CAF0)

GUISetState(@SW_SHOW)

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

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $AForm1

Case $Radio1

Case $Button1

Case $Button2

Case $Label1

EndSwitch

WEnd

anything.au3

Share this post


Link to post
Share on other sites



Something like this :

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=C:\Documents and Settings\CurrentUser\Desktop\Robots\AForm1.kxf
$AForm1 = GUICreate("Dialog", 278, 186, 439, 211)
GUISetIcon("D:09.ico")
$GroupBox1 = GUICtrlCreateGroup("", 8, 32, 161, 145)
$Radio1 = GUICtrlCreateRadio(" Tony", 32, 56, 113, 17)
GUICtrlSetFont(-1, 12, 800, 2, "Times New Roman")
GUICtrlSetColor(-1, 0x800000)
GUICtrlSetBkColor(-1, 0xA6CAF0)
GUICtrlSetState ($Radio1, $GUI_CHECKED); arbitrary
$Radio2 = GUICtrlCreateRadio(" Greg", 32, 96, 113, 17)
GUICtrlSetFont(-1, 12, 800, 2, "Times New Roman")
GUICtrlSetColor(-1, 0x800000)
GUICtrlSetBkColor(-1, 0xA6CAF0)
$Radio3 = GUICtrlCreateRadio(" Randy", 32, 136, 113, 17)
GUICtrlSetFont(-1, 12, 800, 2, "Times New Roman")
GUICtrlSetColor(-1, 0x800000)
GUICtrlSetBkColor(-1, 0xA6CAF0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("&OK", 184, 40, 75, 25, 0)
$Button2 = GUICtrlCreateButton("&Cancel", 184, 72, 75, 25, 0)
$Label1 = GUICtrlCreateLabel("Choose Appraiser for New Zapp", 8, 8, 262, 26)
GUICtrlSetFont(-1, 14, 800, 2, "Times New Roman")
GUICtrlSetColor(-1, 0x800000)
GUICtrlSetBkColor(-1, 0xA6CAF0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

    Case $Button1
        run_selected()

    Case $Button2
    Exit
EndSwitch
WEnd 

Func run_selected()
    If BitAND(GUICtrlRead($Radio1), $GUI_CHECKED) = $GUI_CHECKED Then Run("H:\Program Files\AutoIt3\autoit3.exe your_script1.au3")
    If BitAND(GUICtrlRead($Radio2), $GUI_CHECKED) = $GUI_CHECKED Then Run("H:\Program Files\AutoIt3\autoit3.exe your_script2.au3")
    If BitAND(GUICtrlRead($Radio3), $GUI_CHECKED) = $GUI_CHECKED Then Run("H:\Program Files\AutoIt3\autoit3.exe your_script3.au3")

EndFunc

Share this post


Link to post
Share on other sites

Something like this :

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=C:\Documents and Settings\CurrentUser\Desktop\Robots\AForm1.kxf
$AForm1 = GUICreate("Dialog", 278, 186, 439, 211)
GUISetIcon("D:09.ico")
$GroupBox1 = GUICtrlCreateGroup("", 8, 32, 161, 145)
$Radio1 = GUICtrlCreateRadio(" Tony", 32, 56, 113, 17)
GUICtrlSetFont(-1, 12, 800, 2, "Times New Roman")
GUICtrlSetColor(-1, 0x800000)
GUICtrlSetBkColor(-1, 0xA6CAF0)
GUICtrlSetState ($Radio1, $GUI_CHECKED); arbitrary
$Radio2 = GUICtrlCreateRadio(" Greg", 32, 96, 113, 17)
GUICtrlSetFont(-1, 12, 800, 2, "Times New Roman")
GUICtrlSetColor(-1, 0x800000)
GUICtrlSetBkColor(-1, 0xA6CAF0)
$Radio3 = GUICtrlCreateRadio(" Randy", 32, 136, 113, 17)
GUICtrlSetFont(-1, 12, 800, 2, "Times New Roman")
GUICtrlSetColor(-1, 0x800000)
GUICtrlSetBkColor(-1, 0xA6CAF0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("&OK", 184, 40, 75, 25, 0)
$Button2 = GUICtrlCreateButton("&Cancel", 184, 72, 75, 25, 0)
$Label1 = GUICtrlCreateLabel("Choose Appraiser for New Zapp", 8, 8, 262, 26)
GUICtrlSetFont(-1, 14, 800, 2, "Times New Roman")
GUICtrlSetColor(-1, 0x800000)
GUICtrlSetBkColor(-1, 0xA6CAF0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

    Case $Button1
        run_selected()

    Case $Button2
    Exit
EndSwitch
WEnd 

Func run_selected()
    If BitAND(GUICtrlRead($Radio1), $GUI_CHECKED) = $GUI_CHECKED Then Run("H:\Program Files\AutoIt3\autoit3.exe your_script1.au3")
    If BitAND(GUICtrlRead($Radio2), $GUI_CHECKED) = $GUI_CHECKED Then Run("H:\Program Files\AutoIt3\autoit3.exe your_script2.au3")
    If BitAND(GUICtrlRead($Radio3), $GUI_CHECKED) = $GUI_CHECKED Then Run("H:\Program Files\AutoIt3\autoit3.exe your_script3.au3")

EndFunc

Whoever you are...... Thank you ... really appreciate it.... now I get it.

Thanks again.

TH

Share this post


Link to post
Share on other sites

hy

i use a script just like this.

the problem is:

how i make choose windows ( the window with radio buttons) disapear after i make the choose and i press ok

Share this post


Link to post
Share on other sites

hy

i use a script just like this.

the problem is:

how i make choose windows ( the window with radio buttons) disapear after i make the choose and i press ok

Use GUICtrlSetState on the controls that you want to change the state of after you press OK.

:)

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