Jump to content

gettin radom tekst


Recommended Posts

Hi. ive got this script, and i want to do so that $Question1 and $Question2 will be randomly putted into $Label1 can anyone help me with this?

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Question1 = "What color is blood?"
$Question2 = "What color is water?"
Global $Form1 = GUICreate("Form1", 349, 89, 192, 124)
Global $Label1 = GUICtrlCreateLabel($Question1, 16, 8, 300, 20)
Global $Button1 = GUICtrlCreateButton("Red", 4, 48, 60, 33)
Global $Button2 = GUICtrlCreateButton("Blue", 64, 48, 60, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $Msg = GUIGetMsg()
    If $Msg = -3 Then Exit
    If $Msg = $Button1 Then Button1()
    If $Msg = $Button2 Then Button2()
WEnd

Func Button1()
    $hej = GUICtrlRead($Label1)
    If $hej = $Question1 Then
        MsgBox(0, "Correct!", "That is correct")
    EndIf
EndFunc
Func Button2()
    $hej = GUICtrlRead($Label1)
    If $hej = $Question1 Then
        MsgBox(0, "Wrong", "That is wrong")
    EndIf
    EndFunc
Edited by bigfattoby

Getting hang on the basic, still much to learn.If I take high class, taking high test im getting highscore right?

Link to comment
Share on other sites

$Questions[2] = ["What color is blood?","What color is water?"] ; put questions into an array
Global $Form1 = GUICreate("Form1", 349, 89, 192, 124)
Global $Label1 = GUICtrlCreateLabel($Questions[Random(0,Ubound($Questions)-1,1)], 16, 8, 300, 20) ; display a random question

Alter rest to suit.

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

Monkey's are, like, natures humans.

Link to comment
Share on other sites

  • Developers

Thanks for trying but that is not working

Working fine assuming you code the rest properly.

for exxample:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Dim $Questions[2] = ["What color is blood?","What color is water?"] ; put questions into an array
Global $Form1 = GUICreate("Form1", 349, 89, 192, 124)
Global $Label1 = GUICtrlCreateLabel($Questions[Random(0,Ubound($Questions)-1,1)], 16, 8, 300, 20) ; display a random question

GUISetState(@SW_SHOW) ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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