Jump to content

Recommended Posts

Posted

Hello,

Please excause how "nooby" this question is but, I gather its better to ask than not.

I have only played with autoit for a few hours, managed to make what looks like a basic GUI, a few boxes e.t.c.

However my question is this:

If I have 2 input boxes, for example "$a" and "$b" how would I get the results of those boxes to show in another place on my GUI, after a button is pressed.

So:

When "calculate button" is pressed $a + $b is shown in a place on my GUI. And each time the calculate button the contents of the boxes will complete which ever maths I program and then show the answer in a seperate place on the GUI.

Help is much appreciated,

Thanks for your time.

Sam.

Posted (edited)

To get what the user has in the input box, use GUICtrlRead()

Example:

$label = GUICtrlCreateLabel("", 25, 25) ; Label that displays calculation
$data = GUICtrlRead($a) + GUICtrlRead($B) ; add the inputs
GUICtrlSetData($label, $data) ; update display
Edited by BALA
[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Posted

Okay, you firstly need to read the input boxes, this can be done with GUICtrlRead():

$readinput1 = GUICtrlRead($firstinput)
$readinput2 = GUICtrlRead($secondinput)oÝ÷ Ù8^znµº1zÈZ½éèÁ··v)è¶«Âݳ ¢Ûaz)ߢ¹¶*'{"uëaz)éºÖèÄÚ0Á鮲×!jxjVzWè­ìZ^¶az×±¶Øb±Æ§mçhì"¶ +k'­
«Zjëh×6GUICtrlSetData($label1, $readinput1)
GUICtrlSetData($label2, $readinput2)

Tell me if you have trouble understanding and I will explain more clearly,

Kurt

Awaiting Diablo III..

Posted

Okay, you firstly need to read the input boxes, this can be done with GUICtrlRead():

$readinput1 = GUICtrlRead($firstinput)
$readinput2 = GUICtrlRead($secondinput)oÝ÷ Ù8^znµº1zÈZ½éèÁ··v)è¶«Âݳ ¢Ûaz)ߢ¹¶*'{"uëaz)éºÖèÄÚ0Á鮲×!jxjVzWè­ìZ^¶az×±¶Øb±Æ§mçhì"¶ +k'­
«Zjëh×6GUICtrlSetData($label1, $readinput1)
GUICtrlSetData($label2, $readinput2)

Tell me if you have trouble understanding and I will explain more clearly,

Kurt

Thats a realy nice example, thanks a load for taking the time :).
Posted

I have been trying to get a better feel for this, I manged to get it to add the results of some questions that were running as question boxes rather than input fields on my GUI.

The code below shows what I have, could somebody give me some pointers please?

; Script Start - Add your code below here
#include <GUIConstants.au3>
#NoTrayIcon
#NoTrayIcon
Global $GUI = GUICreate("Test-addition", 600, 300)
GUISetBkColor(0x00E0FFFF)
GUICtrlCreateLabel("Please Enter the length for the 2 values that you have.", 10, 10)
GUICtrlCreateLabel("Click the Calculate button when entered.", 10, 25)
GUICtrlCreateLabel("value a", 45, 80)
$a = GUICtrlCreateInput("", 10, 100, 60, 20)
GUICtrlCreateLabel("value b", 105, 80)
$b = GUICtrlCreateInput("", 80, 100, 60, 20)
$calculate = GUICtrlCreateButton("Calculate", 500,100, 50)
$answer_text= GUICtrlCreateLabel("Answer:", 160, 100)
$answer = GUICtrlCreateLabel("", 200, 100) 
GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $calculate Then
    $part1 = ($a+$B)
    $data = GUICtrlRead ($part1)
    GUICtrlSetData($answer, $data) 
    EndIf
Wend
Posted (edited)

You need to GUICtrlRead for both $a and $b

#include <GUIConstants.au3>
#NoTrayIcon
#NoTrayIcon
Global $GUI = GUICreate("Test-addition", 600, 300)
GUISetBkColor(0x00E0FFFF)
GUICtrlCreateLabel("Please Enter the length for the 2 values that you have.", 10, 10)
GUICtrlCreateLabel("Click the Calculate button when entered.", 10, 25)
GUICtrlCreateLabel("value a", 45, 80)
$a = GUICtrlCreateInput("", 10, 100, 60, 20)
GUICtrlCreateLabel("value b", 105, 80)
$b = GUICtrlCreateInput("", 80, 100, 60, 20)
$calculate = GUICtrlCreateButton("Calculate", 500,100, 50)
$answer_text= GUICtrlCreateLabel("Answer:", 160, 100)
$answer = GUICtrlCreateLabel("", 200, 100)
GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $calculate Then
    $data = GUICtrlRead($a) + GUICtrlRead($B) ; reads input and calculates their sum
    GUICtrlSetData($answer, $data)
    EndIf
Wend

EDIT: Edited mistake in code

Edited by BALA
[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

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
×
×
  • Create New...