Jump to content

GUICtrlCreateInput question


Maurizio
 Share

Recommended Posts

Hi Foro
I would like to kindly ask you how I have to do to write in input 2 and 4 what the user types on Input 1 and 3
Thank you

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Group1 = GUICtrlCreateGroup("Group1", 56, 56, 497, 217)
$Input1 = GUICtrlCreateInput("Input1", 88, 104, 121, 21)
$Input2 = GUICtrlCreateInput("Input2", 88, 144, 121, 21)
$Input3 = GUICtrlCreateInput("Input3", 272, 104, 105, 21)
$Input4 = GUICtrlCreateInput("Input4", 272, 144, 105, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

    EndSwitch
WEnd

 

Link to comment
Share on other sites

Hi Maurizio :)
Registering WM_COMMAND should do it

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

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Group1 = GUICtrlCreateGroup("Group1", 56, 56, 497, 217)
$Input1 = GUICtrlCreateInput("Input1", 88, 104, 121, 21)
$Input2 = GUICtrlCreateInput("Input2", 88, 144, 121, 21)
$Input3 = GUICtrlCreateInput("Input3", 272, 104, 105, 21)
$Input4 = GUICtrlCreateInput("Input4", 272, 144, 105, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

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

    EndSwitch
WEnd

;=============================================
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    ; Local $hWndFrom = $lParam
    Local $iIDFrom = BitAND($wParam, 0xFFFF)
    Local $iCode = BitShift($wParam, 16)

    Switch $iCode
        Case $EN_CHANGE
            Switch $iIDFrom
                Case $Input1
                    GUICtrlSetData($Input2, GUICtrlRead($Input1))
                Case $Input3
                    GUICtrlSetData($Input4, GUICtrlRead($Input3))
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc

 

 

Link to comment
Share on other sites

I tried this code that you kindly passed me, but it doesn't write anything back.
What I would like to do is insert a number in the Input1 box and receive the total in the Input2 box in the sense: If I first write 10 in Input1, in the Input2 box, I will have 10. Then if I go back to writing another number in the Input1 box, type 20, in the Input2 box I will have 30, that is 10 + 20.

Link to comment
Share on other sites

It happens that if I have to type a three-digit number in the Input1 box, in Input2 it already adds the first number I type. Example, if I type 21 in Input1, in Input2 it writes 23 because it adds up the 2, and the 21.
It would need to write the number only after it has finished writing, perhaps with a key or simply by pressing enter.

Link to comment
Share on other sites

Link to comment
Share on other sites

No the problem is not deleting the fields, but the fact that if I write a two-digit number, it reads it as if they were 2 numbers, for example: if I write 21 he adds 2 + 21 because he does not wait for you to finish writing, but adds immediately. It would take a key that says to add only when pressed.

Link to comment
Share on other sites

 

Certainly, imagine, indeed thanks. :)

 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Group1 = GUICtrlCreateGroup("Group1", 56, 56, 481, 225)
$Input1 = GUICtrlCreateInput("Input1", 80, 96, 153, 21)
$Input2 = GUICtrlCreateInput("Input2", 328, 96, 161, 21)
$Input3 = GUICtrlCreateInput("Input3", 80, 160, 153, 21)
$Input4 = GUICtrlCreateInput("Input4", 328, 160, 169, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

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

    EndSwitch
WEnd

;=============================================
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    ; Local $hWndFrom = $lParam
    Local $iIDFrom = BitAND($wParam, 0xFFFF)
    Local $iCode = BitShift($wParam, 16)

    Switch $iCode
        Case $EN_CHANGE
            Switch $iIDFrom
                Case $Input1
                    GUICtrlSetData($Input2, GUICtrlRead($Input1) + GUICtrlRead($Input2))
                Case $Input3
                   GUICtrlSetData($Input4, GUICtrlRead($Input3) + GUICtrlRead($Input4))
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc

 

Link to comment
Share on other sites

Hi,

i would do it in this way:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Group1 = GUICtrlCreateGroup("Group1", 56, 56, 481, 225)
$Input1 = GUICtrlCreateInput("Input1", 80, 96, 153, 21)
$Input2 = GUICtrlCreateInput("Input2", 328, 96, 161, 21)
$Input3 = GUICtrlCreateInput("Input3", 80, 160, 153, 21)
$Input4 = GUICtrlCreateInput("Input4", 328, 160, 169, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

Global $tTimer1, $tTimer2, $fInput1 = 0, $fInput2 = 0

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

    If TimerDiff($tTimer1) > 1500 And $fInput1 = 0 Then
        $fInput1 = 1
        GUICtrlSetData($Input2, GUICtrlRead($Input1) + GUICtrlRead($Input2))
    EndIf

    If TimerDiff($tTimer2) > 1500 And $fInput2 = 0 Then
        $fInput2 = 1
        GUICtrlSetData($Input4, GUICtrlRead($Input3) + GUICtrlRead($Input4))
    EndIf

WEnd

;=============================================
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    ; Local $hWndFrom = $lParam
    Local $iIDFrom = BitAND($wParam, 0xFFFF)
    Local $iCode = BitShift($wParam, 16)

    Switch $iCode
        Case $EN_CHANGE
            Switch $iIDFrom
                Case $Input1
                    $tTimer1 = TimerInit()
                    $fInput1 = 0
                    ;GUICtrlSetData($Input2, GUICtrlRead($Input1) + GUICtrlRead($Input2))
                Case $Input3
                    $tTimer2 = TimerInit()
                    $fInput2 = 0
                    ;GUICtrlSetData($Input4, GUICtrlRead($Input3) + GUICtrlRead($Input4))
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

the timing can be adjusted in this line:

If TimerDiff($tTimer1) > 1500

 

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