Sign in to follow this  
Followers 0
3jameo3

GUICtrlCreateInput not registering the right answer

14 posts in this topic

Script:

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

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Basic Calc", 546, 290, 192, 114)
$Label1 = GUICtrlCreateLabel("Price of Paper", 8, 16, 150, 33)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Amount Per Ream", 8, 72, 194, 41)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("Quanitity of Reams", 8, 128, 194, 41)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
$Input1 = GUICtrlCreateInput("0", 224, 24, 49, 21)
$Input2 = GUICtrlCreateInput("0", 312, 24, 49, 21)
$Input3 = GUICtrlCreateInput("0", 400, 24, 49, 21)
$Input4 = GUICtrlCreateInput("0", 488, 24, 49, 21)
$Input5 = GUICtrlCreateInput("0", 224, 80, 49, 21)
$Input6 = GUICtrlCreateInput("0", 224, 136, 49, 21)
$Label4 = GUICtrlCreateLabel("Amount Needed", 8, 184, 179, 41)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
$var0 = $Input5
$var1 = $Input6
$var2 = $Input1
$var3 = $Input2
$var4 = $Input3
$var5 = $Input4
$var6 = $var0 * $var1 * $var2
$var7 = $var0 * $var1 * $var3
$var8 = $var0 * $var1 * $var4
$var9 = $var0 * $var1 * $var5
$InputA = GUICtrlCreateInput($var6, 224, 192, 49, 21, BitOR($ES_READONLY, $ES_CENTER), $WS_EX_STATICEDGE)
$InputB = GUICtrlCreateInput($var7, 312, 192, 49, 21, BitOR($ES_READONLY, $ES_CENTER), $WS_EX_STATICEDGE)
$InputC = GUICtrlCreateInput($var8, 400, 192, 49, 21, BitOR($ES_READONLY, $ES_CENTER), $WS_EX_STATICEDGE)
$InputD = GUICtrlCreateInput($var9, 488, 192, 49, 21, BitOR($ES_READONLY, $ES_CENTER), $WS_EX_STATICEDGE)
$Button1 = GUICtrlCreateButton("Calculate Amount Needed", 104, 240, 321, 41)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Local $i = 0
Local $msg
Do
    $msg = GUIGetMsg()
    If ($msg = -3) Then
        $i = 1
    EndIf
    Select
        Case ($msg = $Button1)
            $final1 = ($var0 * $var1)
            Assign($var6, ($final1 * $var2))
            $final1 = ($var0 * $var1)
            Assign($var7, ($final1 * $var3))
            $final1 = ($var0 * $var1)
            Assign($var8, ($final1 * $var4))
            $final1 = ($var0 * $var1)
            Assign($var9, ($final1 * $var5))
    EndSelect
Until $i = 1

As you can see i've tried to fix this a few different ways the answers are always 660 770 880 990 in that order and i have no idea what is the cause for this. No matter if i remove the button info or try to make the button set var6-9 its always the same. I've tried Execute in the Vars, I just got done trying Assign in the button, I've tried GUICtrlSetData and read im not sure what else to try truthfully. Any help resolving this through any way possible would be great.

Also I cannot seem to find a way to limit for example:

$InputD = GUICtrlCreateInput($var9, 488, 192, 49, 21, BitOR($ES_READONLY, $ES_CENTER), $WS_EX_STATICEDGE)

Basically i'm wanting to make it so every thousand goes to the next readonly input box Ex 1000 $var9 = 1 $var8 and so on until $var6 kind of like what the commas do for a calculator but in different boxes and no commas.

Thanks in Advance for any and all help given.

Share this post


Link to post
Share on other sites



#4 ·  Posted (edited)

The read value of an input with "" inside is 0  :)

$Input1 = GUICtrlCreateInput("now", 224, 24, 49, 21)
$Input2 = GUICtrlCreateInput("this", 312, 24, 49, 21)
$Input3 = GUICtrlCreateInput("is", 400, 24, 49, 21)
$Input4 = GUICtrlCreateInput("not 0", 488, 24, 49, 21)
$Input5 = GUICtrlCreateInput("any", 224, 80, 49, 21)
$Input6 = GUICtrlCreateInput("more", 224, 136, 49, 21)
$var0 = GUICtrlRead($Input5)
$var1 = GUICtrlRead($Input6)
$var2 = GUICtrlRead($Input1)
$var3 = GUICtrlRead($Input2)
$var4 = GUICtrlRead($Input3)
$var5 = GUICtrlRead($Input4)

For maths try to put numeric values instead of strings

Edited by mikell

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

The read value of an input with "" inside is 0  :)

$Input1 = GUICtrlCreateInput("now", 224, 24, 49, 21)
$Input2 = GUICtrlCreateInput("this", 312, 24, 49, 21)
$Input3 = GUICtrlCreateInput("is", 400, 24, 49, 21)
$Input4 = GUICtrlCreateInput("not 0", 488, 24, 49, 21)
$Input5 = GUICtrlCreateInput("any", 224, 80, 49, 21)
$Input6 = GUICtrlCreateInput("more", 224, 136, 49, 21)
$var0 = GUICtrlRead($Input5)
$var1 = GUICtrlRead($Input6)
$var2 = GUICtrlRead($Input1)
$var3 = GUICtrlRead($Input2)
$var4 = GUICtrlRead($Input3)
$var5 = GUICtrlRead($Input4)

For maths try to put numeric values instead of strings

still is registering 0 ive tried everything but its just not wanting to go above 0 in the Amount Needed section

$Input1 = GUICtrlCreateInput("a", 224, 24, 49, 21)
$Input2 = GUICtrlCreateInput("a", 312, 24, 49, 21)
$Input3 = GUICtrlCreateInput("a", 400, 24, 49, 21)
$Input4 = GUICtrlCreateInput("a", 488, 24, 49, 21)
$Input5 = GUICtrlCreateInput("a", 224, 80, 49, 21)
$Input6 = GUICtrlCreateInput("a", 224, 136, 49, 21)
$var0 = GUICtrlRead($Input5)
$var1 = GUICtrlRead($Input6)
$var2 = GUICtrlRead($Input1)
$var3 = GUICtrlRead($Input2)
$var4 = GUICtrlRead($Input3)
$var5 = GUICtrlRead($Input4)
$var6 = Execute($var0 * $var1 * $var2)
$var7 = Execute($var0 * $var1 * $var3)
$var8 = Execute($var0 * $var1 * $var4)
$var9 = Execute($var0 * $var1 * $var5)
$InputA = GUICtrlCreateInput($var6, 224, 192, 49, 21, BitOR($ES_CENTER,$ES_READONLY), $WS_EX_STATICEDGE)
$InputB = GUICtrlCreateInput($var7, 312, 192, 49, 21, BitOR($ES_CENTER,$ES_READONLY), $WS_EX_STATICEDGE)
$InputC = GUICtrlCreateInput($var8, 400, 192, 49, 21, BitOR($ES_CENTER,$ES_READONLY), $WS_EX_STATICEDGE)
$InputD = GUICtrlCreateInput($var9, 488, 192, 49, 21, BitOR($ES_CENTER,$ES_READONLY), $WS_EX_STATICEDGE)
$Button1 = GUICtrlCreateButton("Calculate Amount Needed", 104, 240, 321, 41)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    Select
        Case ($nMsg = $Button1)
            $final1 = ($var0 * $var1)
            Assign($var6, ($final1 * $var2))
            $final1 = ($var0 * $var1)
            Assign($var7, ($final1 * $var3))
            $final1 = ($var0 * $var1)
            Assign($var8, ($final1 * $var4))
            $final1 = ($var0 * $var1)
            Assign($var9, ($final1 * $var5))
    EndSelect
    EndSwitch
WEnd
Edited by 3jameo3

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

basically all it does is

1. input the price of an item (any item)                                       [millions] then [thousands] then [Hundreds] then [tens]

2. next input how many of this item are in a bundle together     [Amount]

3. next you input how many bundles of the item                        [Amount2]

4. then it gives the total cost                                                      [millions] then [thousands] then [Hundreds] then [tens]

total cost is calculated buy 1[1-4] x amount x amount2

total cost needs a limiter so only the values specified will show in the correct places so basically limit of 999 before moving to the next place holder

this could be used for games to calculate trading costs simply or for any person wanting an easy calculator

sadly instead of it showing the total amount its ONLY showing 0's now

Edited by 3jameo3

Share this post


Link to post
Share on other sites

Try getting shut of the execute functions.

$var6 = $var0 * $var1 * $var2
$var7 = $var0 * $var1 * $var3
$var8 = $var0 * $var1 * $var4
$var9 = $var0 * $var1 * $var5

And by the way you do not expect anything to change when you click your button do you?

Because no fields are set when it is.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Try getting shut of the execute functions.

$var6 = $var0 * $var1 * $var2
$var7 = $var0 * $var1 * $var3
$var8 = $var0 * $var1 * $var4
$var9 = $var0 * $var1 * $var5

And by the way you do not expect anything to change when you click your button do you?

Because no fields are set when it is.

ive already tried that way as well and no luck sadly

the button thing is well idk yet i havent got the whole button thing down just yet, not even sure if that's the problem but if i'm thinking right it should automatically calculate the inputs how the $var's are set up of course i may be wrong.

if it does have to run through the button im not exactly sure on how to set it up correctly i've tried many different variations but with the exact same results.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

weird maybe its the AutoIt program itself not doing the compiling correctly when im testing ill reinstall it and see what happens

any ideas on how to set up my little program to have limiters on the tens hundreds thousands and millions places?

quick edit  

just reinstalled still no change whatsoever even doing it the way you said john maybe i have a faulty program im not sure what version are you using?

Edited by 3jameo3

Share this post


Link to post
Share on other sites

anyone who can run this script after fixing it using JohnOne's fix please let me know the version of AutoIt you are using i'm thinking 3.3.12.0 is bugged on my system (windows 7 home 64bit)

Share this post


Link to post
Share on other sites

What is bugged is your helpfile reading I guess

John said :

"And by the way you do not expect anything to change when you click your button do you?

Because no fields are set when it is."

#include <ButtonConstants.au3>
#include <GuiButton.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
 
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Basic Calc", 546, 290, 192, 114)
$Label1 = GUICtrlCreateLabel("Price of Paper", 8, 16, 150, 33)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Amount Per Ream", 8, 72, 194, 41)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("Quanitity of Reams", 8, 128, 194, 41)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Input1 = GUICtrlCreateInput("1", 224, 24, 49, 21)
$Input2 = GUICtrlCreateInput("2", 312, 24, 49, 21)
$Input3 = GUICtrlCreateInput("3", 400, 24, 49, 21)
$Input4 = GUICtrlCreateInput("4", 488, 24, 49, 21)
$Input5 = GUICtrlCreateInput("5", 224, 80, 49, 21)
$Input6 = GUICtrlCreateInput("6", 224, 136, 49, 21)
$Label4 = GUICtrlCreateLabel("Amount Needed", 8, 184, 179, 41)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
$var0 = GUICtrlRead($Input5)
$var1 = GUICtrlRead($Input6)
$var2 = GUICtrlRead($Input1)
$var3 = GUICtrlRead($Input2)
$var4 = GUICtrlRead($Input3)
$var5 = GUICtrlRead($Input4)
$var6 = $var0 * $var1 * $var2
$var7 = $var0 * $var1 * $var3
$var8 = $var0 * $var1 * $var4
$var9 = $var0 * $var1 * $var5
$InputA = GUICtrlCreateInput($var6, 224, 192, 49, 21, BitOR($ES_READONLY, $ES_CENTER), $WS_EX_STATICEDGE)
$InputB = GUICtrlCreateInput($var7, 312, 192, 49, 21, BitOR($ES_READONLY, $ES_CENTER), $WS_EX_STATICEDGE)
$InputC = GUICtrlCreateInput($var8, 400, 192, 49, 21, BitOR($ES_READONLY, $ES_CENTER), $WS_EX_STATICEDGE)
$InputD = GUICtrlCreateInput($var9, 488, 192, 49, 21, BitOR($ES_READONLY, $ES_CENTER), $WS_EX_STATICEDGE)
$Button1 = GUICtrlCreateButton("Calculate Amount Needed", 104, 240, 321, 41)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
 
Local $i = 0
Local $msg
Do
    $msg = GUIGetMsg()
    If ($msg = -3) Then
        $i = 1
    EndIf
    Select
        Case ($msg = $Button1)
    $var0 = GUICtrlRead($Input5)
    $var1 = GUICtrlRead($Input6)
    $var2 = GUICtrlRead($Input1)
    $var3 = GUICtrlRead($Input2)
    $var4 = GUICtrlRead($Input3)
    $var5 = GUICtrlRead($Input4)
    GuiCtrlSetData($InputA, $var0 * $var1 * $var2)
    GuiCtrlSetData($InputB, $var0 * $var1 * $var3)
    GuiCtrlSetData($InputC, $var0 * $var1 * $var4)
    GuiCtrlSetData($InputD, $var0 * $var1 * $var5)
    EndSelect
Until $i = 1

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

How is it when i tried that combination for the button it didnt work but when you did it, it works lmao. Ii must have mistyped something in an earlier version of the script. Thanks for the help guys i really appreciate it. Now to work on limiters so my values dont go over 1000 per output box but instead at 1000 they carry over to the next one right to left

Edited by 3jameo3

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  
Followers 0