Jump to content

Two Questions


Phaethon
 Share

Recommended Posts

Hey everyone. I'm working on a little project, and I have run into 2 problems.

Firstly, I need a way to make double digit numbers. Allow me to explain. I have 9 buttons, and each has a number (1-9) on it. When the user clicks on 1 of them, I need it to be put into a variable, but also, when they click on 2 in a row (say the click 1,1) I want it to be read as 11. I need help on how to do this.

Secondly, I have an input box (GuiCtrlCreateInput) on my GUI, and I need it to be updated with a new character everytime someone pushes a button on my GUI.

Any help is appreciated :)

Coder's Helper >> Here[center][/center]

Link to comment
Share on other sites

It would look something like this:

; Assuming button '5'
GUICtrlSetData($Input_1, GUICtrlRead($Input_1) & '5')

The variable $Input_1 is the control ID of the input.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Have no fear. WeaponX is here.

#include <GUIConstants.au3>

GUICreate("My GUI", 200, 200)  ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)       ; will display an empty dialog box

Dim $btnArray[9]

$input = GUICtrlCreateInput ( "", 40, 5, 120)

$num = 0
For $Y = 1 to 3
    For $X = 1 to 3
        $btnArray[$num] = GUICtrlCreateButton ( $num + 1, $X * 40, $Y * 40, 40, 40)
        $num += 1
    Next
Next

Func update($num)
    $currentnum = GuiCtrlRead($input)
    If $currentnum >= 10 Then
        GuiCtrlSetData($input,$num)
    Else
        GuiCtrlSetData($input,$currentnum & $num)
    EndIf
EndFunc

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $btnArray[0]
            update(1)
        Case $btnArray[1]
            update(2)
        Case $btnArray[2]
            update(3)
        Case $btnArray[3]
            update(4)
        Case $btnArray[4]
            update(5)
        Case $btnArray[5]
            update(6)
        Case $btnArray[6]
            update(7)
        Case $btnArray[7]
            update(8)
        Case $btnArray[8]
            update(9)
    EndSwitch
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
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...