Jump to content
zetaimmersion

Change state of Input field

Recommended Posts

zetaimmersion

I have 2 items (a field box and a bypass checkbox). every time the box is checked i need the field to become writable. unchecked is read only displaying some text.

this is as far as i got as I am stuck at making it read/write toggle

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

$hGUI = GUICreate("Test", 500, 500)

Global $hCombo = GUICtrlCreateInput("", 10, 10, 200, 20, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetBkColor($hCombo,0xe7e5e5)

Global $cbox = GUICtrlCreateCheckbox ("", 40,50,10,20)
GUICtrlSetState($cbox, $GUI_Unchecked)
GUISetState()

Global $sCurrCombo = ""

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cbox
            If GUICtrlRead($cbox) <> $sCurrCombo Then
                $sCurrCombo = GUICtrlRead($cbox)
                GUICtrlSetStyle ($hCombo, $SS_LEFTNOWORDWRAP)
                GUICtrlSetBkColor($hCombo,0xFFFFFF)
                MsgBox(0, "Choice", "PLease enter the text")
            EndIf
    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites
KickStarter15

Hi,

How about having it this way:

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cbox
            If GUICtrlRead($cbox) <> $GUI_UNCHECKED Then
                $sCurrCombo = GUICtrlRead($cbox)
                GUICtrlSetStyle ($hCombo, $SS_LEFTNOWORDWRAP)
                GUICtrlSetBkColor($hCombo,0xFFFFFF)
                MsgBox(0, "Choice", "PLease enter the text")
             ElseIf GUICtrlRead($cbox) <> $GUI_CHECKED Then
                GUICtrlSetState($hCombo, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
            EndIf
    EndSwitch
WEnd

Would that suffice you?

Edited by KickStarter15

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Share this post


Link to post
Share on other sites
benners
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("Test", 500, 500)

Global $hCombo = GUICtrlCreateInput("", 10, 10, 200, 20)
GUICtrlSetState($hCombo, $GUI_DISABLE)

Global $cbox = GUICtrlCreateCheckbox ("", 40,50,10,20)

GUISetState()

Global $sCurrCombo = ""

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cbox
            if GUICtrlRead($cbox) = $GUI_CHECKED Then
                GUICtrlSetState($hCombo, $GUI_ENABLE)
                MsgBox(0, "Choice", "PLease enter the text")
            Else
                GUICtrlSetState($hCombo, $GUI_DISABLE)
            EndIf
    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites
zetaimmersion

yup. all good. thanks guys. appreciate the quick reply

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

  • Similar Content

    • Lisuter
      By Lisuter
      Hello...

      How i can write data from txt to +3 Input?
      Example:
      In txt i have:
      Michael XYZ, 21, Boston
      Olex Marshal, 17, Boston
      Alex XYZ, 19, Boston
       
      And now i want load that data to input in autoit. 

      Name          y.o          city
      [ Input1]  [Input2] [Input3]
      [ Input4]  [Input5] [Input6]
      [ Input7]  [Input8] [Input9]
       
      After load should be:
      Name               y.o            city
      [Michael XYZ]      [21]     [Boston]
      [ Olex Marshal]  [17]      [Boston]
      [ Alex XYZ]           [19]      [Boston]
       
      FileOpen("Test.txt",0)                          $aas = GUICtrlSetData($Input1, FileReadLine("Test.txt",1))             FileClose("Test.txt") But its wrong. ofcourse its load all to input 1. So now how do you load this data directly into each input separately? The comma stop sign is here. Each line is a new person
    • Blois
      By Blois
      Hi Guis,
       
      I need to create keyboard shortcut to navigate the tabs and activate them, but I could not use the code below:
      #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <GUIConstantsEx.au3> HotKeySet("^{TAB}", "_TabRight") HotKeySet("^+{TAB}", "_TabLeft") $gui = GUICreate("test",450, 300) $Tab1 = GUICtrlCreateTab(20, 24, 425, 201) $TabSheet1 = GUICtrlCreateTabItem("Tabsheet 1") $lbContagemGrupos2 = GUICtrlCreateLabel("aaaa", 50, 50) GUICtrlSetColor(-1, 0x0000FF) GUICtrlCreateTabItem("") $TabSheet2 = GUICtrlCreateTabItem(" ") $TabSheet3 = GUICtrlCreateTabItem(" ") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _TabRight() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos + 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Func _TabLeft() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos - 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Exit  
      can you help me?
    • smud
      By smud
      Currently, I'm working on a program that will display Dialog boxes with either Yes or No.
      For each dialog, I reward the user with X amount of Credits.
      I'm hoping to output the amount of credits to a cell in a column (there will be 20 different columns).
      It will only post to a row that is equal to today's date (first column). If no row exists yet with the current date, it will start a new row.
      Any suggestions?
      Thank you
    • Pricehacker
      By Pricehacker
      Hello again!
      I have tried searching for quite some time now but couldn´t find a single working way to change the class of your GUI that doesn´t include changing it manually after its compilation.
      First or "AutoIt v3 GUI" is a pretty boring name tbh and i would like to spice it up a bit, also, and more importantly, I would like to identify my windows by something other than its title as it will change depending on some factors and im using two different programs independently as multi threading isn't supported.
      Any help is appreciated! Thank you!
    • xtcislove
      By xtcislove
      Hello, 
      i have a Problem with  _WinAPI_SetLayeredWindowAttributes, everything is working as excepted if u are on Windows 7.

      But if u are on Windows 10 the transparent background of a control is not clickable anymore. 

      Could someone help?

      Please see example below, put cmd.jpg into the same folder as Example.au3

      Please see trigger.jpg to see which sections are not clickable in Windows 10 (the red dots, the green dots are clickable) on Windows 7 the red ones and green ones are clickable.
       
      The same problem occurs if i use 
       
       
      Example.au3


×