Jump to content

Combox --> If...then


Markir
 Share

Recommended Posts

Hello everbody,

I want to code the following:

Then the combobox is = Lotus Notes 5 or Lotus Notes 6 or Lotus Notes 6.5 the following Input fields should be enabled, how can I get this function?

This is the code:

GUICtrlCreateCombo ("", 110,0,180)
$var = GUICtrlSetData(-1,"Exchange 5.5|Exchange 2000|Exchange2003|Lotus Notes 5|Lotus Notes 6|Lotus Notes 6.5", "")

If $var = ("Lotus Notes 5") Then
    
GUICtrlCreateLabel ("Lotus Notes User",-110,25,100,20)
GUICtrlCreateInput ("",110,0,180)
GUICtrlSetState(-1,$GUI_ENABLE)   ; the label is in disable state
GUICtrlCreateLabel ("Lotus Notes Domain",240,0,100,20)
GUICtrlCreateInput ("",110,0,180)
GUICtrlSetState(-1,$GUI_ENABLE)   ; the label is in disable state
GUICtrlCreateLabel ("XPressions Domain",-460,25,100,20)
GUICtrlCreateInput ("",110,0,180)
GUICtrlSetState(-1,$GUI_ENABLE)   ; the label is in disable state
GUICtrlCreateLabel ("FaxG3 Alias",240,0,100,20)
GUICtrlCreateInput ("",110,0,180)
GUICtrlSetState(-1,$GUI_ENABLE)   ; the label is in disable state
GUICtrlCreateLabel ("FaxG4 Alias",-460,25,100,20)
GUICtrlCreateInput ("",110,0,180)
GUICtrlSetState(-1,$GUI_ENABLE)   ; the label is in disable state
GUICtrlCreateLabel ("FaxG3Rev Alias",240,0,100,20)
GUICtrlCreateInput ("",110,0,180)
GUICtrlSetState(-1,$GUI_ENABLE)   ; the label is in disable state
GUICtrlCreateLabel ("SMS Alias",-460,25,100,20)
GUICtrlCreateInput ("",110,0,180)
GUICtrlSetState(-1,$GUI_ENABLE)   ; the label is in disable state

    Else

GUICtrlCreateLabel ("Lotus Notes User",-110,25,100,20)
GUICtrlCreateInput ("",110,0,180)
GUICtrlSetState(-1,$GUI_DISABLE)   ; the label is in disable state
GUICtrlCreateLabel ("Lotus Notes Domain",240,0,100,20)
GUICtrlCreateInput ("",110,0,180)
GUICtrlSetState(-1,$GUI_DISABLE)   ; the label is in disable state
GUICtrlCreateLabel ("XPressions Domain",-460,25,100,20)
GUICtrlCreateInput ("",110,0,180)
GUICtrlSetState(-1,$GUI_DISABLE)   ; the label is in disable state
GUICtrlCreateLabel ("FaxG3 Alias",240,0,100,20)
GUICtrlCreateInput ("",110,0,180)
GUICtrlSetState(-1,$GUI_DISABLE)   ; the label is in disable state
GUICtrlCreateLabel ("FaxG4 Alias",-460,25,100,20)
GUICtrlCreateInput ("",110,0,180)
GUICtrlSetState(-1,$GUI_DISABLE)   ; the label is in disable state
GUICtrlCreateLabel ("FaxG3Rev Alias",240,0,100,20)
GUICtrlCreateInput ("",110,0,180)
GUICtrlSetState(-1,$GUI_DISABLE)   ; the label is in disable state
GUICtrlCreateLabel ("SMS Alias",-460,25,100,20)
GUICtrlCreateInput ("",110,0,180)
GUICtrlSetState(-1,$GUI_DISABLE)   ; the label is in disable state

EndIf
Link to comment
Share on other sites

Not exactly what you want, but here's an example of one way to approach the problem:

#include <GuiConstants.au3>

GuiCreate("Example")

$combo = GuiCtrlCreateCombo("", 10, 10, 100, 100)
GuiCtrlSetData($combo, "one|two|three")

$button_1 = GuiCtrlCreateButton("#1", 10, 100, 30, 30)
$button_2 = GuiCtrlCreateButton("#2", 110, 100, 30, 30)
$button_3 = GuiCtrlCreateButton("#3", 210, 100, 30, 30)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        
    If GuiCtrlRead($combo) = "one" Then
        GuiCtrlSetState($button_1, $GUI_ENABLE)
        GuiCtrlSetState($button_2, $GUI_DISABLE)
        GuiCtrlSetState($button_3, $GUI_DISABLE)
    ElseIf GuiCtrlRead($combo) = "two" Then
        GuiCtrlSetState($button_2, $GUI_ENABLE)
        GuiCtrlSetState($button_1, $GUI_DISABLE)
        GuiCtrlSetState($button_3, $GUI_DISABLE)
    ElseIf GuiCtrlRead($combo) = "three" Then
        GuiCtrlSetState($button_3, $GUI_ENABLE)
        GuiCtrlSetState($button_1, $GUI_DISABLE)
        GuiCtrlSetState($button_2, $GUI_DISABLE)
    Else
        GuiCtrlSetState($button_1, $GUI_DISABLE)
        GuiCtrlSetState($button_2, $GUI_DISABLE)
        GuiCtrlSetState($button_3, $GUI_DISABLE)
    EndIf
WEnd
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

Hello,

I want to get the following function:

If the User selected Lotus Notes 5 or Lotus Notes 6 or Lotus Notes 6.5, then

the Inputfield of "Lotus Notes User" should be enabled. I hope anybody can help me!

$combo = GUICtrlCreateCombo ("", 110,0,180)
GUICtrlSetData($combo, "Exchange 5.5|Exchange 2000|Exchange2003|Lotus Notes 5|Lotus Notes 6|Lotus Notes 6.5", "")

If GuiCtrlRead($combo) = "Lotus Notes 5" Then
    
GUICtrlCreateLabel ("Lotus Notes User",-460,25,100,20)
GUICtrlCreateInput ("",110,0,180)
GUICtrlSetState(-1,$GUI_ENABLE)  ; the label is in Enable state

    Else

GUICtrlCreateLabel ("Lotus Notes User",-460,25,100,20)
GUICtrlCreateInput ("",110,0,180)
GUICtrlSetState(-1,$GUI_DISABLE)  ; the label is in disable state
EndIf
Edited by Markir
Link to comment
Share on other sites

When somebody dropdown the item "Lotus Notes 5" then the following input fields 32-38 should be enabled. What's wrong with my code?

GUICtrlCreateLabel ("Mail Server",10,25,100,20)
$input30 = GUICtrlCreateCombo ($file30,100,0,120)
GUICtrlSetData(-1,"Exchange 5.5|Exchange 2000|Exchange2003|Lotus Notes 5|Lotus Notes 6|Lotus Notes 6.5", $file30)
GUICtrlSetState($input30, $file30)
GUICtrlCreateLabel ("IP Mail-Server",-100,25,100,20)
$input31 = GUICtrlCreateInput ($file31,100,0,120)
GUICtrlSetState($input31, $file31)

If $input30 = ("Lotus Notes 5") Then
    
GUICtrlCreateLabel ("Lotus Notes User",-100,25,100,20)
$input32 = GUICtrlCreateInput ($file32,100,0,120)
GUICtrlSetState($input32, $file32)
GUICtrlSetState(-1,$GUI_ENABLE)   ; the label is in enable state
GUICtrlCreateLabel ("Lotus Notes Domain",-100,25,100,20)
$input33 = GUICtrlCreateInput ($file33,100,0,120)
GUICtrlSetState($input33, $file33)
GUICtrlSetState(-1,$GUI_ENABLE)   ; the label is in enable state
GUICtrlCreateLabel ("XPressions Domain",-100,25,100,20)
$input34 = GUICtrlCreateInput ($file34,100,0,120)
GUICtrlSetState($input34, $file34)
GUICtrlSetState(-1,$GUI_ENABLE)   ; the label is in enable state
GUICtrlCreateLabel ("FaxG3 Alias",-100,25,100,20)
$input35 = GUICtrlCreateInput ($file35,100,0,120)
GUICtrlSetState($input35, $file35)
GUICtrlSetState(-1,$GUI_ENABLE)   ; the label is in enable state
GUICtrlCreateLabel ("FaxG4 Alias",-100,25,100,20)
$input36 = GUICtrlCreateInput ($file36,100,0,120)
GUICtrlSetState($input36, $file36)
GUICtrlSetState(-1,$GUI_ENABLE)   ; the label is in enable state
GUICtrlCreateLabel ("FaxG3Rev Alias",-100,25,100,20)
$input37 = GUICtrlCreateInput ($file37,100,0,120)
GUICtrlSetState($input37, $file37)
GUICtrlSetState(-1,$GUI_ENABLE)   ; the label is in enable state
GUICtrlCreateLabel ("SMS Alias",-100,25,100,20)
$input38 = GUICtrlCreateInput ($file38,100,0,120)
GUICtrlSetState($input38, $file38)
GUICtrlSetState(-1,$GUI_ENABLE)   ; the label is in enable state

Else
    
GUICtrlCreateLabel ("Lotus Notes User",-100,25,100,20)
$input32 = GUICtrlCreateInput ($file32,100,0,120)
GUICtrlSetState(-1,$GUI_DISABLE)   ; the label is in disable state
GUICtrlCreateLabel ("Lotus Notes Domain",-100,25,100,20)
$input33 = GUICtrlCreateInput ($file33,100,0,120)
GUICtrlSetState(-1,$GUI_DISABLE)   ; the label is in disable state
GUICtrlCreateLabel ("XPressions Domain",-100,25,100,20)
$input34 = GUICtrlCreateInput ($file34,100,0,120)
GUICtrlSetState(-1,$GUI_DISABLE)   ; the label is in disable state
GUICtrlCreateLabel ("FaxG3 Alias",-100,25,100,20)
$input35 = GUICtrlCreateInput ($file35,100,0,120)
GUICtrlSetState(-1,$GUI_DISABLE)   ; the label is in disable state
GUICtrlCreateLabel ("FaxG4 Alias",-100,25,100,20)
$input36 = GUICtrlCreateInput ($file36,100,0,120)
GUICtrlSetState(-1,$GUI_DISABLE)   ; the label is in disable state
GUICtrlCreateLabel ("FaxG3Rev Alias",-100,25,100,20)
$input37 = GUICtrlCreateInput ($file37,100,0,120)
GUICtrlSetState(-1,$GUI_DISABLE)   ; the label is in disable state
GUICtrlCreateLabel ("SMS Alias",-100,25,100,20)
$input38 = GUICtrlCreateInput ($file38,100,0,120)
GUICtrlSetState(-1,$GUI_DISABLE)   ; the label is in disable state

EndIf
Link to comment
Share on other sites

  • Developers

Have somebody an idea to find the right code for that?

<{POST_SNAPBACK}>

markir, the piece of code you posted is totally confusing to me.

You are testing $input30 which is a handle NOT the value of the control.

Further, you are testing at a location in the code where the Combo box isn't displayed yet.....

maybe you need to study the examples in the helpfile a bit more on how to build-up the Gui layout and how to test/act up on events ......

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Hello Jdeb,

have you any idea, after seeing the code and the screenshot above?

<{POST_SNAPBACK}>

Cannot see the screen shot... get some sort of login window...

Think i have some idea of what you want but its all about you learning to do it yourself with our help .... right ? :lmao:

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Okay how can you help me, that I can learn something from that?

<{POST_SNAPBACK}>

Did you look at the example Cyberslug posted ?

Try to change your posted script to follow that kind of logic for starters.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Okay I have changed my Code to the following:

While 1
    $msg = GuiGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        
If GUICtrlRead($input30) = "Lotus Notes 5" Then
    

GUICtrlSetState($input31,$GUI_ENABLE)   ; the label is in enable state
GUICtrlSetState($input32,$GUI_ENABLE)   ; the label is in enable state
GUICtrlSetState($input33,$GUI_ENABLE)   ; the label is in enable state
GUICtrlSetState($input34,$GUI_ENABLE)   ; the label is in enable state
GUICtrlSetState($input35,$GUI_ENABLE)   ; the label is in enable state
GUICtrlSetState($input36,$GUI_ENABLE)   ; the label is in enable state
GUICtrlSetState($input37,$GUI_ENABLE)   ; the label is in enable state
GUICtrlSetState($input38,$GUI_ENABLE)   ; the label is in enable state

EndIf

WEnd

But now, no GUI will be started?

Edited by Markir
Link to comment
Share on other sites

  • Developers

k... hope this helps a bit :lmao: :

#include <guiconstants.au3>
$file30 = "Lotus Notes 5"
$file31 = "test 1"
$file32 = "test 2"
$file33 = "test 3"
$file34 = "test 4"
$file35 = "test 5"
$file36 = "test 6"
$file37 = "test 7"
$file38 = "test 8"
opt("GUICoordMode",0)
GUICreate("test")
GUICtrlCreateLabel("Mail Server", 10, 25, 100, 20)
$input30 = GUICtrlCreateCombo("", 100, 0, 120,80)
GUICtrlSetData(-1, "Exchange 5.5|Exchange 2000|Exchange2003|Lotus Notes 5|Lotus Notes 6|Lotus Notes 6.5", $file30)
GUICtrlCreateLabel("IP Mail-Server", -100, 25, 100, 20)
$input31 = GUICtrlCreateInput($file31, 100, 0, 120)
GUICtrlCreateLabel("Lotus Notes User", -100, 25, 100, 20)
$input32 = GUICtrlCreateInput($file32, 100, 0, 120)
GUICtrlCreateLabel("Lotus Notes Domain", -100, 25, 100, 20)
$input33 = GUICtrlCreateInput($file33, 100, 0, 120)
GUICtrlCreateLabel("XPressions Domain", -100, 25, 100, 20)
$input34 = GUICtrlCreateInput($file34, 100, 0, 120)
GUICtrlCreateLabel("FaxG3 Alias", -100, 25, 100, 20)
$input35 = GUICtrlCreateInput($file35, 100, 0, 120)
GUICtrlCreateLabel("FaxG4 Alias", -100, 25, 100, 20)
$input36 = GUICtrlCreateInput($file36, 100, 0, 120)
GUICtrlCreateLabel("FaxG3Rev Alias", -100, 25, 100, 20)
$input37 = GUICtrlCreateInput($file37, 100, 0, 120)
GUICtrlCreateLabel("SMS Alias", -100, 25, 100, 20)
$input38 = GUICtrlCreateInput($file38, 100, 0, 120)
SetState($file30)
GUISetState()
; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $input30 Then
        SetState(GUICtrlRead($input30))
    EndIf
WEnd
;
Func SetState($selected)
    If $selected = ("Lotus Notes 5") Then
        $setstate = $GUI_ENABLE
    Else
        $setstate = $GUI_DISABLE
    EndIf
    GUICtrlSetState($input31, $setstate)
    GUICtrlSetState($input32, $setstate)
    GUICtrlSetState($input33, $setstate)
    GUICtrlSetState($input34, $setstate)
    GUICtrlSetState($input35, $setstate)
    GUICtrlSetState($input36, $setstate)
    GUICtrlSetState($input37, $setstate)
    GUICtrlSetState($input38, $setstate)
EndFunc  ;==>SetState
Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Hello Jdeb,

ok I have understood this code. In a new project without other functions it works perfectly, but in the whole project it doesn't work. On all options it will be enabled, her ethe code:

$file30 = "Lotus Notes 5"

$file31 = "test 1"

$file32 = "test 2"

$file33 = "test 3"

$file34 = "test 4"

$file35 = "test 5"

$file36 = "test 6"

$file37 = "test 7"

$file38 = "test 8"

GUICtrlCreateGroup ("Anschaltung",-420,40,260,255)

GUICtrlCreateLabel("Mail Server", 10, 25, 100, 20)

$input30 = GUICtrlCreateCombo("", 100, 0, 120,80)

GUICtrlSetData(-1, "Exchange 5.5|Exchange 2000|Exchange2003|Lotus Notes 5|Lotus Notes 6|Lotus Notes 6.5", $file30)

GUICtrlCreateLabel("IP Mail-Server", -100, 25, 100, 20)

$input31 = GUICtrlCreateInput($file31, 100, 0, 120)

GUICtrlCreateLabel("Lotus Notes User", -100, 25, 100, 20)

$input32 = GUICtrlCreateInput($file32, 100, 0, 120)

GUICtrlCreateLabel("Lotus Notes Domain", -100, 25, 100, 20)

$input33 = GUICtrlCreateInput($file33, 100, 0, 120)

GUICtrlCreateLabel("XPressions Domain", -100, 25, 100, 20)

$input34 = GUICtrlCreateInput($file34, 100, 0, 120)

GUICtrlCreateLabel("FaxG3 Alias", -100, 25, 100, 20)

$input35 = GUICtrlCreateInput($file35, 100, 0, 120)

GUICtrlCreateLabel("FaxG4 Alias", -100, 25, 100, 20)

$input36 = GUICtrlCreateInput($file36, 100, 0, 120)

GUICtrlCreateLabel("FaxG3Rev Alias", -100, 25, 100, 20)

$input37 = GUICtrlCreateInput($file37, 100, 0, 120)

GUICtrlCreateLabel("SMS Alias", -100, 25, 100, 20)

$input38 = GUICtrlCreateInput($file38, 100, 0, 120)

SetState($file30)

Guisetstate()

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

If $msg = $input30 Then

SetState(GUICtrlRead($input30))

EndIf

Wend

Func SetState($selected)

If $selected = ("Lotus Notes 5") Then

$setstate = $GUI_ENABLE

Else

$setstate = $GUI_DISABLE

EndIf

GUICtrlSetState($input31, $setstate)

GUICtrlSetState($input32, $setstate)

GUICtrlSetState($input33, $setstate)

GUICtrlSetState($input34, $setstate)

GUICtrlSetState($input35, $setstate)

GUICtrlSetState($input36, $setstate)

GUICtrlSetState($input37, $setstate)

GUICtrlSetState($input38, $setstate)

EndFunc

Link to comment
Share on other sites

  • Developers

Don't understand what you are asking me....

The script you post is more or less what i posted and works.

If it doesn't work in another script then you need to do some debugging to see why it doesn't work. I normally do that with ConsoleWrite() or MSGBox() statements in the script telling me whjats happening. When you are using SciTE then you can generate these statement by using Alt+d or Ctrl+Shift+d...

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

@Jdeb Where should I set the messagebox?

<{POST_SNAPBACK}>

when you want to know what is happening in your script you just add msgboxes or consolewrites at those places in your script where you want to know if it gets there..... so i don't know where ... that is something you need to determine for yourself...

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...