Jump to content

Noob Needs Some Direction


Recommended Posts

Help please.

I am very new to the world of scripting let alone AutoIt. If someone can help me out that would be greatly appreciated. I am trying to create text output to the clip board. I have been looking at the help files. I have been looking at other scripts. I just dont get it. Below is a very remedial GUI I created. If someone could fill in the blanks to create the proper output for me I would be very grateful.

GUI

#include <GUIConstants.au3

$Form1 = GUICreate("Dog Cat", 196, 295, 192, 125)

$Group1 = GUICtrlCreateGroup("Animal", 48, 16, 121, 89)

$Radio1 = GUICtrlCreateRadio("Dog", 56, 40, 81, 17)

$Radio2 = GUICtrlCreateRadio("Cat", 56, 64, 81, 25)

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

$Group2 = GUICtrlCreateGroup("Toy", 48, 128, 121, 81)

$Radio3 = GUICtrlCreateRadio("Bone", 56, 144, 89, 25)

$Radio4 = GUICtrlCreateRadio("String", 56, 176, 89, 17)

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

$Button1 = GUICtrlCreateButton("Reset", 24, 240, 73, 41, 0)

$Button2 = GUICtrlCreateButton("Copy", 112, 240, 73, 41, 0)

GUISetState(@SW_SHOW)

While 1

$msg = GuiGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case Else

EndSelect

WEnd

The output would be The dog likes his bone or The cat likes his string etc

Like I said this is very remedial, I am hoping to learn.

Thank you to anyone that can help me. If I am posting in the wrong area please let me know.

Link to comment
Share on other sites

maybe...

#include <GUIConstants.au3>
$Form1 = GUICreate("Dog Cat", 196, 295, 192, 125)
$Group1 = GUICtrlCreateGroup("Animal", 48, 16, 121, 89)
$Radio1 = GUICtrlCreateRadio("Dog", 56, 40, 81, 17)
GUICtrlSetState( -1, $GUI_CHECKED)
$Radio2 = GUICtrlCreateRadio("Cat", 56, 64, 81, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Toy", 48, 128, 121, 81)
$Radio3 = GUICtrlCreateRadio("Bone", 56, 144, 89, 25)
GUICtrlSetState( -1, $GUI_CHECKED)
$Radio4 = GUICtrlCreateRadio("String", 56, 176, 89, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("Reset", 24, 240, 73, 41, 0)
$Button2 = GUICtrlCreateButton("Copy", 112, 240, 73, 41, 0)
GUISetState(@SW_SHOW)
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button2
    If BitAnd(GUICtrlRead($Radio1),$GUI_CHECKED) = $GUI_CHECKED Then
        $G1_info = "Dog"
    Else
        $G1_info = "Cat"
    EndIf
    If BitAnd(GUICtrlRead($Radio3),$GUI_CHECKED) = $GUI_CHECKED Then
        $G2_info = "Bone"
    Else
        $G2_info = "String"
    EndIf
    MsgBox(64, " Info read is...", $G1_info & " " & $G2_info & "  ", 2)
    ClipPut($G1_info & " " & $G2_info)
Case Else

EndSelect
WEnd

8)

NEWHeader1.png

Link to comment
Share on other sites

In order to determine if a control has been activated, put "Case $msg = $ControlID" in your While Loop. After I determined that the "Start" button was pushed, I used GUICtrlRead() to determine the state of each of the radio buttons, and construct my string accordingly.

#include <GUIConstants.au3>
$Form1 = GUICreate("Dog Cat", 196, 295, 192, 125)
$Group1 = GUICtrlCreateGroup("Animal", 48, 16, 121, 89)
$Radio1 = GUICtrlCreateRadio("Dog", 56, 40, 81, 17)
$Radio2 = GUICtrlCreateRadio("Cat", 56, 64, 81, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Toy", 48, 128, 121, 81)
$Radio3 = GUICtrlCreateRadio("Bone", 56, 144, 89, 25)
$Radio4 = GUICtrlCreateRadio("String", 56, 176, 89, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("Reset", 24, 240, 73, 41, 0)
$Button2 = GUICtrlCreateButton("Copy", 112, 240, 73, 41, 0)
GUISetState(@SW_SHOW)

$_GUI_CHECKED = BitAND($GUI_CHECKED, $GUI_ENABLE)
$_GUI_UNCHECKED = BitAND($GUI_CHECKED, $GUI_ENABLE)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button1
            GUICtrlSetState($Radio1, $GUI_UNCHECKED)
            GUICtrlSetState($Radio2, $GUI_UNCHECKED)
            GUICtrlSetState($Radio3, $GUI_UNCHECKED)
            GUICtrlSetState($Radio4, $GUI_UNCHECKED)
        Case $msg = $Button2
            $string = ""
            If GUICtrlRead($Radio1) == $GUI_CHECKED Then
                $string &= "The Dog "
            ElseIf GUICtrlRead($Radio2) == $GUI_CHECKED Then
                $string &= "The Cat "
            EndIf
            If GUICtrlRead($radio3) == $GUI_CHECKED Then
                $string &= "likes his Bone."
            ElseIf GUICtrlRead($radio4) == $GUI_CHECKED Then
                $string &= "likes his String."
            EndIf
            ClipPut($string)
            MsgBox(0,"",$string)
        Case Else
            
    EndSelect
WEnd

Edit: Hah! Waaaay too slow for Valuater.

Edited by neogia

[u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...