Sign in to follow this  
Followers 0
craigholohan

Controle buttons

7 posts in this topic

Hi Guys,

Ok this may be a little silly, but for the life of me I cant figure it out so I need some help please?

My objective here is to call the On Screen Keyboard, but before you are able to call it you need to do a little calculation.

As you can see from my screen shot, I have created a GUI with the number pad, an input box and at the top there are 6 Label's.

The calculation will be the first number x second number + forth number + sixth number, in my example screen shot the answer would be 35, so if you click the 3 and the 5 and then click the enter button the app needs to call C:\%systemroot%\system32\osk.exe and if you get the answer incorrect then the app simply should exit.

OK, so I have managed to get the 6 labels to generate random numbers every time the app is run, so that works.

But what I can't get working at this point is when I click on the buttons it has to put that number into the input box.

This means I am stuck at this point and cant go any further, please any help would be greatly appreciated, I am having sleepless night over this.

Thanks in advance,

Craig

Share this post


Link to post
Share on other sites



well without the code to look at example:

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button1
            GUICtrlSetData($inputbox, $number1)
        Case $msg = $button2
            GUICtrlSetData($inputbox, $number2)
;etc...
    EndSelect
WEnd

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

well without the code to look at example:

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button1
            GUICtrlSetData($inputbox, $number1)
        Case $msg = $button2
            GUICtrlSetData($inputbox, $number2)
;etc...
    EndSelect
WEnd

<{POST_SNAPBACK}>

Sorry, her is what I have so far:

#include <GuiConstants.au3>

#include <Array.au3>

; GUI

GuiCreate("Launch Keyboard", 400, 450)

GuiSetIcon("Icons\AppIcon.ico")

; PIC

;GuiCtrlCreatePic("Icons\ZUDM.jpg",0,0, 160,76)

;Random Numbers

Dim $myArray[Random(1, 9, 1)][Random(1, 9, 1)][Random(1, 9, 1)][Random(1, 9, 1)][Random(1, 9,

1)][Random(1, 9, 1)] ;element 0,0 to 9,19

$one = UBound($myArray)

$two = UBound($myArray, 2)

$three = UBound($myArray, 3)

$four = UBound($myArray, 4)

$five = UBound($myArray, 5)

$six = UBound($myArray, 6)

GuiCtrlCreateGroup("", 180 , 0 , 190, 90)

GUISetFont (20, 400, 0, "")

GuiCtrlCreateLabel($one, 190, 10)

GuiCtrlCreateLabel($two, 220, 10)

GuiCtrlCreateLabel($three, 250, 10)

GuiCtrlCreateLabel($four, 280, 10)

GuiCtrlCreateLabel($five, 310, 10)

GuiCtrlCreateLabel($six, 340, 10)

GUICtrlCreateGroup ("",-99,-99,1,1) ;close group

;Font

GUISetFont (20, 400, 0, "")

; BUTTON

$button7 = GUICtrlCreateButton ("7", 70,100,80,80,"")

$button8 = GUICtrlCreateButton ("8", 150,100,80,80,"")

$button9 = GUICtrlCreateButton ("9", 230,100,80,80,"")

$button4 = GUICtrlCreateButton ("4", 70,180,80,80,"")

$button5 = GUICtrlCreateButton ("5", 150,180,80,80,"")

$button6 = GUICtrlCreateButton ("6", 230,180,80,80,"")

$button1 = GUICtrlCreateButton ("1", 70,260,80,80,"")

$button2 = GUICtrlCreateButton ("2", 150,260,80,80,"")

$button3 = GUICtrlCreateButton ("3", 230,260,80,80,"")

$button0 = GUICtrlCreateButton ("0", 70,340,80,80,"")

$buttonEnt = GUICtrlCreateButton ("Enter", 150,340,160,80,"")

;Font

GUISetFont (20, 400, 0, "")

;Input Box

$Myinput=GuiCtrlCreateInput( "", 180, 50, 190, 40)

; GUI MESSAGE LOOP

GuiSetState()

While 1

WEnd

Share this post


Link to post
Share on other sites

Hope you don't mind made an array of the buttons, easier to work code with

but here's something that should point you in the direction i think your trying to go with this.

#include <GuiConstants.au3>
#include <Array.au3>


; GUI
GUICreate("Launch Keyboard", 400, 450)
GUISetIcon("Icons\AppIcon.ico")

; PIC
;GuiCtrlCreatePic("Icons\ZUDM.jpg",0,0, 160,76)

;~;Random Numbers
Dim $myArray[Random(1, 9, 1) ][Random(1, 9, 1) ][Random(1, 9, 1) ][Random(1, 9, 1) ][Random(1, 9, 1) ][Random(1, 9, 1) ];element 0,0 to 9,19
$one = UBound($myArray)
$two = UBound($myArray, 2)
$three = UBound($myArray, 3)
$four = UBound($myArray, 4)
$five = UBound($myArray, 5)
$six = UBound($myArray, 6)

GUICtrlCreateGroup("", 180, 0, 190, 90)
GUISetFont(20, 400, 0, "")
GUICtrlCreateLabel($one, 190, 10)
GUICtrlCreateLabel($two, 220, 10)
GUICtrlCreateLabel($three, 250, 10)
GUICtrlCreateLabel($four, 280, 10)
GUICtrlCreateLabel($five, 310, 10)
GUICtrlCreateLabel($six, 340, 10)
GUICtrlCreateGroup("", -99, -99, 1, 1);close group

;Font
GUISetFont(20, 400, 0, "")
Dim $button[11]
$button[0] = 10
; BUTTON
$button[8] = GUICtrlCreateButton("7", 70, 100, 80, 80, "")
$button[9] = GUICtrlCreateButton("8", 150, 100, 80, 80, "")
$button[10] = GUICtrlCreateButton("9", 230, 100, 80, 80, "")
$button[5] = GUICtrlCreateButton("4", 70, 180, 80, 80, "")
$button[6] = GUICtrlCreateButton("5", 150, 180, 80, 80, "")
$button[7] = GUICtrlCreateButton("6", 230, 180, 80, 80, "")
$button[2] = GUICtrlCreateButton("1", 70, 260, 80, 80, "")
$button[3] = GUICtrlCreateButton("2", 150, 260, 80, 80, "")
$button[4] = GUICtrlCreateButton("3", 230, 260, 80, 80, "")
$button[1] = GUICtrlCreateButton("0", 70, 340, 80, 80, "")
$buttonEnt = GUICtrlCreateButton("Enter", 150, 340, 160, 80, "")

;Font
GUISetFont(20, 400, 0, "")
;Input Box
$Myinput = GUICtrlCreateInput("", 180, 50, 190, 40)

; GUI MESSAGE LOOP
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $buttonEnt
        ; your code here
        Case Else
            For $x = 1 To $button[0]
                If $msg == $button[$x] Then
                    ConsoleWrite($msg & @LF & $button[$x] & @LF)
                    GUICtrlSetData($Myinput, $x)
                    ExitLoop
                EndIf
            Next
    EndSelect
WEnd

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Hope you don't mind made an array of the buttons, easier to work code with

but here's something that should point you in the direction i think your trying to go with this.

#include <GuiConstants.au3>
#include <Array.au3>
; GUI
GUICreate("Launch Keyboard", 400, 450)
GUISetIcon("Icons\AppIcon.ico")

; PIC
;GuiCtrlCreatePic("Icons\ZUDM.jpg",0,0, 160,76)

;~;Random Numbers
Dim $myArray[Random(1, 9, 1) ][Random(1, 9, 1) ][Random(1, 9, 1) ][Random(1, 9, 1) ][Random(1, 9, 1) ][Random(1, 9, 1) ];element 0,0 to 9,19
$one = UBound($myArray)
$two = UBound($myArray, 2)
$three = UBound($myArray, 3)
$four = UBound($myArray, 4)
$five = UBound($myArray, 5)
$six = UBound($myArray, 6)

GUICtrlCreateGroup("", 180, 0, 190, 90)
GUISetFont(20, 400, 0, "")
GUICtrlCreateLabel($one, 190, 10)
GUICtrlCreateLabel($two, 220, 10)
GUICtrlCreateLabel($three, 250, 10)
GUICtrlCreateLabel($four, 280, 10)
GUICtrlCreateLabel($five, 310, 10)
GUICtrlCreateLabel($six, 340, 10)
GUICtrlCreateGroup("", -99, -99, 1, 1);close group

;Font
GUISetFont(20, 400, 0, "")
Dim $button[11]
$button[0] = 10
; BUTTON
$button[8] = GUICtrlCreateButton("7", 70, 100, 80, 80, "")
$button[9] = GUICtrlCreateButton("8", 150, 100, 80, 80, "")
$button[10] = GUICtrlCreateButton("9", 230, 100, 80, 80, "")
$button[5] = GUICtrlCreateButton("4", 70, 180, 80, 80, "")
$button[6] = GUICtrlCreateButton("5", 150, 180, 80, 80, "")
$button[7] = GUICtrlCreateButton("6", 230, 180, 80, 80, "")
$button[2] = GUICtrlCreateButton("1", 70, 260, 80, 80, "")
$button[3] = GUICtrlCreateButton("2", 150, 260, 80, 80, "")
$button[4] = GUICtrlCreateButton("3", 230, 260, 80, 80, "")
$button[1] = GUICtrlCreateButton("0", 70, 340, 80, 80, "")
$buttonEnt = GUICtrlCreateButton("Enter", 150, 340, 160, 80, "")

;Font
GUISetFont(20, 400, 0, "")
;Input Box
$Myinput = GUICtrlCreateInput("", 180, 50, 190, 40)

; GUI MESSAGE LOOP
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $buttonEnt
        ; your code here
        Case Else
            For $x = 1 To $button[0]
                If $msg == $button[$x] Then
                    ConsoleWrite($msg & @LF & $button[$x] & @LF)
                    GUICtrlSetData($Myinput, $x)
                    ExitLoop
                EndIf
            Next
    EndSelect
WEnd

<{POST_SNAPBACK}>

Thanks Gafrost, that is a great help, only thing is how would I get all the numbers I click to appear up in the input box, say like in my screen shot the answer is 35, I click the 3 then the 5 and 35 appears in the input box?

Then I guess I can use one of those if then commands.

Thanks for you help so far,

Craig

Share this post


Link to post
Share on other sites

#include <GuiConstants.au3>
#include <Array.au3>


; GUI
GUICreate("Launch Keyboard", 400, 450)
GUISetIcon("Icons\AppIcon.ico")

; PIC
;GuiCtrlCreatePic("Icons\ZUDM.jpg",0,0, 160,76)

;~;Random Numbers
Dim $myArray[Random(1, 9, 1) ][Random(1, 9, 1) ][Random(1, 9, 1) ][Random(1, 9, 1) ][Random(1, 9, 1) ][Random(1, 9, 1) ];element 0,0 to 9,19
$one = UBound($myArray)
$two = UBound($myArray, 2)
$three = UBound($myArray, 3)
$four = UBound($myArray, 4)
$five = UBound($myArray, 5)
$six = UBound($myArray, 6)

GUICtrlCreateGroup("", 180, 0, 190, 90)
GUISetFont(20, 400, 0, "")
GUICtrlCreateLabel($one, 190, 10)
GUICtrlCreateLabel($two, 220, 10)
GUICtrlCreateLabel($three, 250, 10)
GUICtrlCreateLabel($four, 280, 10)
GUICtrlCreateLabel($five, 310, 10)
GUICtrlCreateLabel($six, 340, 10)
GUICtrlCreateGroup("", -99, -99, 1, 1);close group

;Font
GUISetFont(20, 400, 0, "")
Dim $button[11]
$button[0] = 10
; BUTTON
$button[8] = GUICtrlCreateButton("7", 70, 100, 80, 80, "")
$button[9] = GUICtrlCreateButton("8", 150, 100, 80, 80, "")
$button[10] = GUICtrlCreateButton("9", 230, 100, 80, 80, "")
$button[5] = GUICtrlCreateButton("4", 70, 180, 80, 80, "")
$button[6] = GUICtrlCreateButton("5", 150, 180, 80, 80, "")
$button[7] = GUICtrlCreateButton("6", 230, 180, 80, 80, "")
$button[2] = GUICtrlCreateButton("1", 70, 260, 80, 80, "")
$button[3] = GUICtrlCreateButton("2", 150, 260, 80, 80, "")
$button[4] = GUICtrlCreateButton("3", 230, 260, 80, 80, "")
$button[1] = GUICtrlCreateButton("0", 70, 340, 80, 80, "")
$buttonEnt = GUICtrlCreateButton("Enter", 150, 340, 160, 80, "")

;Font
GUISetFont(20, 400, 0, "")
;Input Box
$Myinput = GUICtrlCreateInput("", 180, 50, 190, 40)
$Answer = ""
; GUI MESSAGE LOOP
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $buttonEnt
            GUICtrlSetData($Myinput, $Answer)
            $Answer = ""
        ; your code here
        Case Else
            For $x = 1 To $button[0]
                If $msg == $button[$x] Then
                    $Answer = $Answer & $x
                    ExitLoop
                EndIf
            Next
    EndSelect
WEnd


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#include <GuiConstants.au3>
#include <Array.au3>
; GUI
GUICreate("Launch Keyboard", 400, 450)
GUISetIcon("Icons\AppIcon.ico")

; PIC
;GuiCtrlCreatePic("Icons\ZUDM.jpg",0,0, 160,76)

;~;Random Numbers
Dim $myArray[Random(1, 9, 1) ][Random(1, 9, 1) ][Random(1, 9, 1) ][Random(1, 9, 1) ][Random(1, 9, 1) ][Random(1, 9, 1) ];element 0,0 to 9,19
$one = UBound($myArray)
$two = UBound($myArray, 2)
$three = UBound($myArray, 3)
$four = UBound($myArray, 4)
$five = UBound($myArray, 5)
$six = UBound($myArray, 6)

GUICtrlCreateGroup("", 180, 0, 190, 90)
GUISetFont(20, 400, 0, "")
GUICtrlCreateLabel($one, 190, 10)
GUICtrlCreateLabel($two, 220, 10)
GUICtrlCreateLabel($three, 250, 10)
GUICtrlCreateLabel($four, 280, 10)
GUICtrlCreateLabel($five, 310, 10)
GUICtrlCreateLabel($six, 340, 10)
GUICtrlCreateGroup("", -99, -99, 1, 1);close group

;Font
GUISetFont(20, 400, 0, "")
Dim $button[11]
$button[0] = 10
; BUTTON
$button[8] = GUICtrlCreateButton("7", 70, 100, 80, 80, "")
$button[9] = GUICtrlCreateButton("8", 150, 100, 80, 80, "")
$button[10] = GUICtrlCreateButton("9", 230, 100, 80, 80, "")
$button[5] = GUICtrlCreateButton("4", 70, 180, 80, 80, "")
$button[6] = GUICtrlCreateButton("5", 150, 180, 80, 80, "")
$button[7] = GUICtrlCreateButton("6", 230, 180, 80, 80, "")
$button[2] = GUICtrlCreateButton("1", 70, 260, 80, 80, "")
$button[3] = GUICtrlCreateButton("2", 150, 260, 80, 80, "")
$button[4] = GUICtrlCreateButton("3", 230, 260, 80, 80, "")
$button[1] = GUICtrlCreateButton("0", 70, 340, 80, 80, "")
$buttonEnt = GUICtrlCreateButton("Enter", 150, 340, 160, 80, "")

;Font
GUISetFont(20, 400, 0, "")
;Input Box
$Myinput = GUICtrlCreateInput("", 180, 50, 190, 40)
$Answer = ""
; GUI MESSAGE LOOP
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $buttonEnt
            GUICtrlSetData($Myinput, $Answer)
            $Answer = ""
        ; your code here
        Case Else
            For $x = 1 To $button[0]
                If $msg == $button[$x] Then
                    $Answer = $Answer & $x
                    ExitLoop
                EndIf
            Next
    EndSelect
WEnd

<{POST_SNAPBACK}>

Thanks, you'r the MAN I can sleep tonight as long as I can get that IF THEN statment to work.

Thanks ever so much,

Craig

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