Jump to content

Recommended Posts

  • Moderators
Posted

Not without an EndIf for the other starting 'if's':

If GUICtrlRead($Radio1) = 'Firefox' Then 
                If GUICtrlRead($Combo_1) = '3-Point Shooter' Then Run('"C:\Program Files\Mozilla Firefox\firefox.exe" www.google.com'
            EndIf
            If GUICtrlRead($Radio2) = 'Internet Explorer' Then 
                If GUICtrlRead($Combo_1) = '3-Point Shooter' Then Run('"C:\Program Files\Internet Explorer\IExplore.exe" www.google.com')
            EndIf

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

well i dont get the errors anymore. but now the button does not execute.

here is my updated script

#include <GuiConstants.au3>
 
 GUICreate("", 300, 300,)
 $Combo_1 = GUICtrlCreateCombo("", 10, 10, 150, 21)
 GUICtrlSetData($Combo_1, 'Google')
 $Button1 = GUICtrlCreateButton('GO', 35, 35, 100, 17)
;RADIO BUTTONS
 $Radio1 = GuiCtrlCreateRadio("Firefox", 100, 140, 180)
 GuiCtrlSetState(-1, $GUI_CHECKED)
 $Radio2 = GuiCtrlCreateRadio("Internet Explorer", 100, 165, 180)
 GUISetState()
 
 While 1
     $MainMsg = GUIGetMsg()
     Select
         Case $MainMsg = $GUI_EVENT_CLOSE
             Exit
         Case $MainMsg = $Button1
             If GUICtrlRead($Radio1) = 'Firefox' Then 
                 If GUICtrlRead($Combo_1) = '3-Point Shooter' Then Run('"C:\Program Files\Mozilla Firefox\firefox.exe" www.google.com'
             EndIf
             If GUICtrlRead($Radio2) = 'Internet Explorer' Then 
                 If GUICtrlRead($Combo_1) = '3-Point Shooter' Then Run('"C:\Program Files\Internet Explorer\IExplore.exe" www.google.com')
             EndIf
     EndSelect          
 WEnd
I am really starting to learn how to piece together the puzzle that is AutoIt. [u]ComboBox RadioButton Help.au3[/u]
  • Moderators
Posted (edited)

well i dont get the errors anymore. but now the button does not execute.

here is my updated script

#include <GuiConstants.au3>
 
 GUICreate("", 300, 300,)
 $Combo_1 = GUICtrlCreateCombo("", 10, 10, 150, 21)
 GUICtrlSetData($Combo_1, 'Google')
 $Button1 = GUICtrlCreateButton('GO', 35, 35, 100, 17)
;RADIO BUTTONS
 $Radio1 = GuiCtrlCreateRadio("Firefox", 100, 140, 180)
 GuiCtrlSetState(-1, $GUI_CHECKED)
 $Radio2 = GuiCtrlCreateRadio("Internet Explorer", 100, 165, 180)
 GUISetState()
 
 While 1
     $MainMsg = GUIGetMsg()
     Select
         Case $MainMsg = $GUI_EVENT_CLOSE
             Exit
         Case $MainMsg = $Button1
             If GUICtrlRead($Radio1) = 'Firefox' Then 
                 If GUICtrlRead($Combo_1) = '3-Point Shooter' Then Run('"C:\Program Files\Mozilla Firefox\firefox.exe" www.google.com'
             EndIf
             If GUICtrlRead($Radio2) = 'Internet Explorer' Then 
                 If GUICtrlRead($Combo_1) = '3-Point Shooter' Then Run('"C:\Program Files\Internet Explorer\IExplore.exe" www.google.com')
             EndIf
     EndSelect          
 WEnd
To be honest, I never checked anything but your 'If' statements... The 'GUICtrlRead()' for the Radio button will return a '4' if it is unchecked and a '1' if it is checked, not the 'Text'.

So... you could do this:

#include <GuiConstants.au3>

GUICreate("", 300, 300,)
$Combo_1 = GUICtrlCreateCombo("", 10, 10, 150, 21)
GUICtrlSetData($Combo_1, 'Google')
$Button1 = GUICtrlCreateButton('GO', 35, 35, 100, 17)
;RADIO BUTTONS
$Radio1 = GuiCtrlCreateRadio("Firefox", 100, 140, 180)
GuiCtrlSetState(-1, $GUI_CHECKED)
$Radio2 = GuiCtrlCreateRadio("Internet Explorer", 100, 165, 180)
GUISetState()

While 1
     $MainMsg = GUIGetMsg()
     Select
         Case $MainMsg = $GUI_EVENT_CLOSE
             Exit
         Case $MainMsg = $Button1
             If GUICtrlRead($Radio1) = 1 Then
                 If GUICtrlRead($Combo_1) = 'Google' Then Run('"C:\Program Files\Mozilla Firefox\firefox.exe" www.google.com')
             EndIf
             If GUICtrlRead($Radio2) = 1 Then
                 If GUICtrlRead($Combo_1) = 'Google' Then Run('"C:\Program Files\Internet Explorer\IExplore.exe" www.google.com')
             EndIf
     EndSelect          
WEnd
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted (edited)

accually i just found out a easier way would be this way

While 1
      $MainMsg = GUIGetMsg()
      Select
          Case $MainMsg = $GUI_EVENT_CLOSE
              Exit
          Case $MainMsg = $Button1
              If GUICtrlRead($Radio1) = 1 and GUICtrlRead($Combo_1) = 'Google' Then Run('"C:\Program Files\Mozilla Firefox\firefox.exe" www.google.com')
              If GUICtrlRead($Radio2) = 1 and GUICtrlRead($Combo_1) = 'Google' Then Run('"C:\Program Files\Internet Explorer\IExplore.exe" www.google.com')
             Endif
 
     EndSelect
 WEnd

Edit: Added the Finished File. Thanks for the help

ComboBox_RadioButton_Help.au3

Edited by HHCory
I am really starting to learn how to piece together the puzzle that is AutoIt. [u]ComboBox RadioButton Help.au3[/u]
  • Moderators
Posted

Nice use of the 'And'.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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
  • Recently Browsing   0 members

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