Jump to content

How to create 100 Input boxes with code?


Razi
 Share

Recommended Posts

I have 3 questions.

1) How to create 100 Input boxes with code?

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 624, 443, 192, 124)

For $y = 0 To 4
  For $a = 0 To 9
    GUICtrlCreateInput('Input' & $a+1 + $y*10, 12+$y*80, 32+$a*32 , 55, 21)
  Next
Next

;GUICtrlSetData($Input2,"Input222") - can't set other text in the $Input2

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

But, I can't change text in the $Input2 or other Input boxes

2) How to change text in the 1 or 10 Input boxes with "For"? The following code doesn't work:

GUICtrlSetData($Input2,"Input222")

3) When above code is pasted in Koda (Form Designer via File->Import->Import Autoit GUI) it doesn't work. How can I make the code above work in the Form designer in order to save, Form with Controls, in Form designer?

Autoit v3.3.14.5; SciTE v.4.4.6. First time using Autoit.

Link to comment
Share on other sites

Here :

#include <GUIConstants.au3>

Local $hGUI = GUICreate("Form1", 624, 443, 192, 124)

Local $aInput[50], $c = 0, $nMsg

For $y = 0 To 4
  For $a = 0 To 9
    $aInput[$c] = GUICtrlCreateInput('Input' & $a + 1 + $y * 10, 12 + $y * 80, 32 + $a * 32, 55, 21)
    $c += 1
  Next
Next

GUICtrlSetData($aInput[2], "Input222")

GUISetState()

While True
  $nMsg = GUIGetMsg()
  Switch $nMsg
    Case $GUI_EVENT_CLOSE
      Exit
    Case $aInput[0] To $aInput[UBound($aInput) - 1]
      ConsoleWrite("Input " & $nMsg - $aInput[0] & " has been modified" & @CRLF)
  EndSwitch
WEnd

ps. Forget using Koda for that kind of design.

Edited by Nine
Link to comment
Share on other sites

2 hours ago, Nine said:

Here :

ps. Forget using Koda for that kind of design.

Thanks. Now the script is working. Still in Koda (Form Designer via File->Import->Import Autoit GUI) the above script creates only 1 Input box.

Link to comment
Share on other sites

Well, you know, there is a way to do it, but ... see for your self:

This is a converter script (  @Nine's  example):

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 531, 369, 192, 124)
Global $Edit1 = GUICtrlCreateEdit("", 1, 0, 527, 367)
GUICtrlSetData(-1, "Edit1")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


Local $aInput[50], $c = 0

For $y = 0 To 4
    For $a = 0 To 9
        memowrite("$aInput[" & $c & "] = GUICtrlCreateInput('Input' & " & $c & "," &  (12 + $y * 80) & "," & (32 + $a * 32) &", 55, 21)")
        $c += 1
    Next
Next





While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func memowrite($txt)
    GUICtrlSetData($Edit1, $txt & @CRLF, 1)
EndFunc   ;==>memowrite

When you run it, it will create all the input boxes definitions.

Then you have to copy the text into the original script and replace the following lines

For $y = 0 To 4
  For $a = 0 To 9
    $aInput[$c] = GUICtrlCreateInput('Input' & $a + 1 + $y * 10, 12 + $y * 80, 32 + $a * 32, 55, 21)
    $c += 1
  Next
Next

with it.

Then it is parseable in the koda form designer.

Edited by Dan_555

Some of my script sourcecode

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