Jump to content
Sign in to follow this  
Bert

GUICtrlread not working

Recommended Posts

Bert

I wrote a example code of the problem:

#include <GUIConstants.au3>
#include <Date.au3>

AutoItSetOption ("TrayIconDebug", 1)
;TAB A
Dim $Header_A = "    Ticket"
Dim $NameA, $TotalTimeA, $UnitA, $countA = 32
Dim $TimerActiveA_[50], $LabelA_[50], $TButtonA_[50], $SButtonA_[50], $InputA_[50]; $LabelA_[50]
Dim $TimeA_[50], $TimerA_[50], $sTimeA_[50], $xkA, $ckA, $LeftA = 0, $TopA = 20, $XA
Dim $InputA1_[50], $InputA2_[50]

Global $TimerReseta = 0,$TimerResetb = 0,$TimerResetc = 0,$TimerResetd = 0
AdlibEnable("AllTimers", 500)

GUICreate("   T(egg) Timer", 871, 170,-1 ,-1 )
GUICtrlSetState(-1,$GUI_DISABLE)
GUICtrlSetCursor(-1, 0)
$h_tab = GUICtrlCreateTab (-1, -1, 895,170)

;FIRST TAB GUI------------------------------------------------------------------------------- 
GUICtrlCreateTabItem("Tickets 1-8")
GUICtrlCreateLabel($Header_A & "s 1 - 8", -20, 23, 890, 18, $SS_CENTER, $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 12, 700)
GUICtrlSetBkColor(-1, 0xCEFFCE)

For $XA = 1 To 8
; row 1
   GUICtrlCreateLabel($Header_A & " " & $XA, $LeftA, $TopA + 25, 80, 20, $SS_CENTER); ticket lable ex: ticket 1
   $LabelA_[$XA] = GUICtrlCreateLabel("", $LeftA, $TopA + 43, 100, 30, 0x00800000 + 0x0001)
   $InputA1_[$XA] = GUICtrlCreateInput("", $LeftA + 80, $TopA + 23, 20, 18, 0x1000)   
   GUICtrlSetFont($LabelA_[$XA], 16)
   GUICtrlSetData($LabelA_[$XA], "00:00:00")
   $TButtonA_[$XA] = GUICtrlCreateButton("Start", $LeftA, $TopA + 73, 50, 20)
   $SButtonA_[$XA] = GUICtrlCreateButton("Stop", $LeftA + 50, $TopA + 73, 50, 20)
   $InputA_[$XA] = GUICtrlCreateInput("", $LeftA, $TopA + 93, 100, 20,0x2000 + 0x1000 + 0x0002)
   $InputA2_[$XA] = GUICtrlCreateInput("", $LeftA, $TopA + 116, 100, 20, 0x1000 + 0x0002)
   $LeftA = $LeftA + 110 
 Next  
;----------------------------------------------------------------------------------------------
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    IF $msg < 1 then ContinueLoop
    Switch GUICtrlRead($h_tab)
        Case 0
            For $xkA = 1 To $countA
              if $msg = $TButtonA_[$xkA] And GUICtrlRead($InputA_[$xkA]) > "" then
                    GUICtrlSetState($TButtonA_[$xkA], $GUI_DISABLE)
                    GUICtrlSetState($InputA_[$xkA], $GUI_DISABLE)
                    $TimerActiveA_[$xkA] = 1
                    
                    If Not StringLen(String($TimerA_[$xkA])) Or $TimerReseta Then 
                        $TimerA_[$xkA] = TimerInit()
                        $TimerReseta = 0
                    Else
                        GUICtrlSetData($SButtonA_[$xkA], "Stop")
                    EndIf
              elseif  $msg = $TButtonA_[$xkA] Then 
                    MsgBox(64, "User Error", "Please Type in a Ticket Number   ", 3)
              endif
              if    $msg = $SButtonA_[$xkA] And GUICtrlRead($SButtonA_[$xkA]) = "Reset" Then
                    GUICtrlSetData($LabelA_[$xkA], "00:00:00")
                    GUICtrlSetData($InputA_[$xkA], "")
                    GUICtrlSetData($InputA2_[$xkA], "")
                    GUICtrlSetData($InputA1_[$XkA], "")
                    GUICtrlSetData($SButtonA_[$xkA], "Stop")
                    $TimerReseta = 1
              endif 
              if    $msg = $SButtonA_[$xkA] And GUICtrlRead($InputA_[$xkA]) <> "" And GUICtrlRead($SButtonA_[$xkA]) = "Stop" Then
                    $TimerActiveA_[$xkA] = 0
                    GUICtrlSetData($SButtonA_[$xkA], "Reset")
                    GUICtrlSetState($TButtonA_[$xkA], $GUI_ENABLE)
                    GUICtrlSetState($InputA_[$xkA], $GUI_ENABLE)
                    GUICtrlSetBkColor($LabelA_[$xkA], 0xD4D0C8)
                    $NameA = GUICtrlRead($InputA_[$xkA])
                   
                    If $xkA < 32 Then
                        $UnitA = $Header_A & "  " & $xkA
                    EndIf
                  endif
                If $xkA = 32 Then ExitLoop 

            Next

    EndSwitch
wend   

Func AllTimers()
    Local $Secs, $Mins, $Hour
  ;first tab
    For $ckA = 1 To $countA
        
        If $TimerActiveA_[$ckA] Then
            _TicksToTime(Int(TimerDiff($TimerA_[$ckA])), $Hour, $Mins, $Secs)
            $TimeA_[$ckA] = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
            If $sTimeA_[$ckA] <> $TimeA_[$ckA] Then GUICtrlSetData($LabelA_[$ckA], $TimeA_[$ckA])
                     
;-----------------------------------------------------------------------------------------------------------------
           ;This is the section giving me trouble. I can change the color of the box, but I can't read it's text
          
            If $Mins == 0 and $Secs == 01 Then ; for testing
               $urg =GUICtrlread($InputA1_[$ckA], 1); - I need it to read the text in this window
               ;if $urg = 1 then                   ; - tried this - didn't work
                msgbox(0, "what number?", $urg) ;tried this also, it does not see anything.
                GUICtrlSetBkColor($InputA1_[$ckA], 0xFFFF00 );It sees this. 
            endif 
;------------------------------------------------------------------------------------------------------------------
        EndIf
   next

EndFunc;==>AllTimers

I marked the section with the problem. I do not understand why I can change the color of the input field, but I can't read what is entered in it.

Share this post


Link to post
Share on other sites
Josbe

Ok, you have:

$urg =GUICtrlread($InputA1_[$ckA], 1); - I need it to read the text in this window

This parameter, like the Helpfile says, returns an array with more info. If you want data only, remove this one.

Share this post


Link to post
Share on other sites
seandisanti

I do not understand why I can change the color of the input field, but I can't read what is entered in it.

here is your issue:

$urg =GUICtrlread($InputA1_[$ckA], 1); - I need it to read the text in this window

you're using the advanced option 1 that tells the control to return an array, then you try to use $urg as a value, but it's an array. you should change that to option 0 (or remove it) if you don't need the additional state information of the control, or access the text by using $urg[1] i believe.

Share this post


Link to post
Share on other sites
seandisanti

opps...man, that was a dumb one on my part. I must need sleep.....ZZZzz :P

it happens to everyone man. glad i could help

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.