Jump to content

Simple but fun


Zaum
 Share

Recommended Posts

Basically it asks you to input a number. If the number is lower then 100 it will do a while loop of opening firefox until you turn of autoit.

$b = InputBox("default", "type a number")
while $b < 100
    run("C:\Program Files\Mozilla Firefox\firefox.exe")
wend
Link to comment
Share on other sites

Oh sorry not everyone is as skilled as you...

Yeah! I'm so skilled!!! Bow down to your programming master. Actually, it doesn't take much skill to make the following program I just decided to make:

$num = Random(0 , 100, 1);not sure this is right
$guess = Inputbox("Guess the number", "Please input a number between 0-100.")

Func check()
If $guess = $num then
msgbox(0, "You win!!!")
Exit
EndIF

If $guess > $num then
msgbox(0, "Your guess is too high.")
Guess()
EndIf

If $guess < $num then
msgbox(0, "Your guess is too low.")
Guess()
EndIf
EndFunc

Func Guess()
$guess = Inputbox("Guess the number", "Please input a number between 0-100.")
Check()
EndIf
EndFunc
OK!!! Maybe that took a bit longer than I would've hoped, and I'm not sure it works, but try something like that. Some tips:

Use the index in the AutoIt help for ideas and keep it open while programming, look at other peoples' work and then try figuring out how it works and or change it and make it your own (but don't post it because it's really not yours) and look at the examples in the Autoit folder and be sure not to post anything unless it's useful or entertaining.

-Mr.Llama

Link to comment
Share on other sites

Yeah! I'm so skilled!!! Bow down to your programming master. Actually, it doesn't take much skill to make the following program I just decided to make:

$num = Random(0 , 100, 1);not sure this is right
$guess = Inputbox("Guess the number", "Please input a number between 0-100.")

Func check()
If $guess = $num then
msgbox(0, "You win!!!")
Exit
EndIF

If $guess > $num then
msgbox(0, "Your guess is too high.")
Guess()
EndIf

If $guess < $num then
msgbox(0, "Your guess is too low.")
Guess()
EndIf
EndFunc

Func Guess()
$guess = Inputbox("Guess the number", "Please input a number between 0-100.")
Check()
EndIf
EndFunc
OK!!! Maybe that took a bit longer than I would've hoped, and I'm not sure it works, but try something like that. Some tips:

Use the index in the AutoIt help for ideas and keep it open while programming, look at other peoples' work and then try figuring out how it works and or change it and make it your own (but don't post it because it's really not yours) and look at the examples in the Autoit folder and be sure not to post anything unless it's useful or entertaining.

-Mr.Llama

Your is a lot more fun ( when it was fixed )

Dim $guess = "", $num


While 1
    
    If $Guess = "" Then
        Guess()
    EndIf
Sleep(20)
WEnd
Func check()
    If $guess = $num Then
        MsgBox(0,"", "You win!!!")
        Exit
    EndIf
    
    If $guess > $num Then
        MsgBox(0,"", "Your guess is too high.")
        Guess()
    EndIf
    
    If $guess < $num Then
        MsgBox(0,"", "Your guess is too low.")
        Guess()
    EndIf
EndFunc  ;==>check

Func Guess()
    $guess = InputBox("Guess the number", "Please input a number between 0-100.")
    If @error then Exit

    $num = Random(0, 100, 1);not sure this is right
    Check()

EndFunc  ;==>Guess

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Your is a lot more fun ( when it was fixed )

Dim $guess = "", $num
While 1
    
    If $Guess = "" Then
        Guess()
    EndIf
Sleep(20)
WEnd
Func check()
    If $guess = $num Then
        MsgBox(0,"", "You win!!!")
        Exit
    EndIf
    
    If $guess > $num Then
        MsgBox(0,"", "Your guess is too high.")
        Guess()
    EndIf
    
    If $guess < $num Then
        MsgBox(0,"", "Your guess is too low.")
        Guess()
    EndIf
EndFunc  ;==>check

Func Guess()
    $guess = InputBox("Guess the number", "Please input a number between 0-100.")
    If @error then Exit

    $num = Random(0, 100, 1);not sure this is right
    Check()

EndFunc  ;==>Guess

8)

Lol! Thanks for fixing it up.

Edit: I'll post many of my script within a day!!! But there's one problem....blizzhackers is currently down!!! That's where I posted my many scripts. O well, I'll find some way to get them!!!

Edited by Mr.Llama
Link to comment
Share on other sites

You know, this has me thinking... how about a lil code challenge, just for fun.

Requirements:

  • Make a GUI-interfaced program for guessing a number between 1 and 100
  • The GUI should have a "reset" button
  • It should also display how many guesses they have taken so far
  • It should notify them if they were too high or too low after each guess
  • The program should validate user input to ensure that only numbers between 1 and 100 are allowed
First one posting fully functioning code before I do (I'm slow and I've never made a GUI proggy... so no worries) gets a cookie. Edited by SpookMeister

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

You know, this has me thinking... how about a lil code challenge, just for fun.

Requirements:

  • Make a GUI-interfaced program for guessing a number between 1 and 100

  • The GUI should have a "reset" button

  • It should also display how many guesses they have taken so far

  • It should notify them if they were too high or too low after each guess

  • The program should validate user input to ensure that only numbers between 1 and 100 are allowed
First one posting fully functioning code before I do (I'm slow and I've never made a GUI proggy... so no worries) gets a cookie.

maybe it should be a little harder? that takes like 0.000000000000000000043 seconds to make...

also i dont think this is a good place to post it..since not many ppl will read it and all ;)

[right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]

Link to comment
Share on other sites

Well, lame as it is... here's my effort:

#include <GUIConstants.au3>

GUICreate("Guess the Number") 
$n1=GUICtrlCreateButton (" guess ",301,200)
$n2=GUICtrlCreateButton (" reset ",180,250)
$n3=GuiCtrlCreateInput("Guess a number between 1-100", 100, 200, 200, 26,$ES_NUMBER)
GUICtrlSetState(-1,$GUI_FOCUS)
GUISetState ()
$num=_reset()
$GuessCount=1
Do
    $click = GUIGetMsg()
    if $click = $n1 then
        $valid=GUICtrlRead($n3)
        If NOT IsInt($valid) Then
            If $valid < 1 Or $valid > 100 Then
                MsgBox(0,"Try again", "You must enter a number between 1 and 100")
            ElseIf $valid < $num Then
                msgbox(0,"Nice try", "Guess number " & $GuessCount & " was too low")
                $GuessCount=$GuessCount+1
            ElseIf $valid > $num Then
                msgbox(0,"Nice try", "Guess number " & $GuessCount & " was too high")
                $GuessCount=$GuessCount+1
            ElseIF $valid = $num Then
                msgbox(0,"Congratulations", $num & " is correct and it only took you " & $GuessCount & " tries.")
            EndIf
        Else
            MsgBox(0,"Try again", "You must enter a number between 1 and 100 " )
        EndIf
    elseif $click = $n2 then
        $num=_reset()
        msgbox(0,"Reset", "A new number has been chosen")
    endif
Until $click = $GUI_EVENT_CLOSE 

Func _reset()
    $x=random(1,100,1)
    $GuessCount=1
    Return $x
EndFunc

Guess I get the cookie all to myself

Edited by SpookMeister

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

What about this?

opt("ExpandVarStrings", 1)
$num = Random(0, 100, 1)
$win = 0
$try = 0

While 1
    $guess = InputBox("Guess the number", "Please input a number between 0-100.")
    If @error Then Exit
    If $guess = $num Then
        MsgBox(0, "", "You win!!!")
        $num = Random(0, 100, 1)
        $try = $try + 1
        $win = $win + 1
    ElseIf $guess > $num Then
        MsgBox(0, "Guess the number", "Your guess is too high.")
        $try = $try + 1
    ElseIf $guess < $num Then
        MsgBox(0, "Guess the number", "Your guess is too low.")
        $try = $try + 1
    EndIf
    If $win = 0 Then
        ToolTip("You have guessed $try$ time(s).@CRLF@And have won $win$ time(s).", 10, 10)
    Else
        $rate = Round($try / $win, 1)
        ToolTip("You have guessed $try$ time(s).@CRLF@And have won $win$ time(s).@CRLF@@CRLF@Your guessing $rate$ time(s) per win.", 10, 10)
    EndIf
WEnd
Edited by gamerman2360
Link to comment
Share on other sites

Or this?

GUICreate("Guess the number", 255, 210, (@DesktopWidth - 255) / 2, (@DesktopHeight - 210) / 2, 0x10CF0000)

opt("ExpandVarStrings", 1)
$instructions = GUICtrlCreateLabel("Guess a number between 1 and 100.", 20, 10, 220, 20)
$number = GUICtrlCreateInput("50", 60, 40, 40, 20, 8192)
$guess = GUICtrlCreateButton("Guess", 140, 40, 38, 25, 0x0001);Edit, made guess the default button
$currentinfo = GUICtrlCreateLabel("", 40, 80, 200, 20)
$totalinfo = GUICtrlCreateLabel("", 40, 120, 180, 100)
GUICtrlSetFont($instructions, 9, 400, 4);Edit, took out default to make it work for non-beta
GUICtrlSetFont($totalinfo, 9, 400, 2)
$win = 0
$try = 0
$num = Random(0, 100, 1)

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = -3
            ExitLoop
        Case $msg = $guess
            $guessednumber = GUICtrlRead($number)
            If $guessednumber = $num Then
                GUICtrlSetData($currentinfo, "You win!!!")
                GUICtrlSetData($currentinfo, "You win!!!")
                $num = Random(0, 100, 1)
                $try = $try + 1
                $win = $win + 1
            ElseIf $guessednumber > $num Then
                GUICtrlSetData($currentinfo, "Your guess is too high.")
                $try = $try + 1
            ElseIf $guessednumber < $num Then
                GUICtrlSetData($currentinfo, "Your guess is too low.")
                $try = $try + 1
            EndIf
            If $win = 0 Then
                GUICtrlSetData($totalinfo, "You have guessed $try$ time(s).@CRLF@And have won $win$ time(s).")
            Else
                $rate = Round($try / $win, 1)
                GUICtrlSetData($totalinfo, "You have guessed $try$ time(s).@CRLF@And have won $win$ time(s).@CRLF@@CRLF@Your guessing $rate$ time(s) per win.")
            EndIf
            GUICtrlSetState($number, 256)
    EndSelect
WEnd
Edited by gamerman2360
Link to comment
Share on other sites

Made it so it gets harder the more you play!

The GUI one is:

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:         Steve B
;
; Script Function:
;    Small game of guess a number between 1 and 100...
;
; ----------------------------------------------------------------------------

GUICreate("Guess the number", 255, 210, (@DesktopWidth - 255) / 2, (@DesktopHeight - 210) / 2, 282001408);style changed to dec for no reason lol!

opt("ExpandVarStrings", 1)
$instructions = GUICtrlCreateLabel("Guess a number between 1 and 100.", 10, 10, 245, 20)
$number = GUICtrlCreateInput(50, 60, 40, 60, 20, 8192)
$guess = GUICtrlCreateButton("Guess", 140, 40, 38, 25, 1)
$currentinfo = GUICtrlCreateLabel("", 40, 80, 200, 40)
$totalinfo = GUICtrlCreateLabel("", 40, 120, 180, 100)
GUICtrlSetFont($instructions, 9, 400, 4)
GUICtrlSetFont($totalinfo, 9, 400, 2)
GUICtrlSetState($number, 256)
$win = 0
$try = 0
$num = Random(1, 100, 1)
$skill = 1
$level = 100

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = -3
            ExitLoop
        Case $msg = $guess
            $guessednumber = GUICtrlRead($number)
            If $guessednumber = $num Then
                $skill = $skill + 1
                If $skill = 05 Then $level = 1000
                If $skill = 15 Then $level = 10000
                If $skill = 35 Then $level = 100000
                GUICtrlSetData($currentinfo, "You win!!!@CRLF@It was $num$!")
                GUICtrlSetData($number, $level / 2)
                GUICtrlSetData($instructions, "Guess a number between 1 and $level$.")
                $num = Random(1, $level, 1)
                $win = $win + 1
            ElseIf $guessednumber > $num Then
                GUICtrlSetData($currentinfo, "Your guess is too high.")
            ElseIf $guessednumber < $num Then
                GUICtrlSetData($currentinfo, "Your guess is too low.")
            EndIf
            $try = $try + 1
            If $win = 0 Then
                GUICtrlSetData($totalinfo, "You have guessed $try$ time(s).@CRLF@And have won $win$ time(s).")
            Else
                $rate = Round($try / $win, 1)
                GUICtrlSetData($totalinfo, "You have guessed $try$ time(s).@CRLF@And have won $win$ time(s).@CRLF@@CRLF@Your guessing $rate$ time(s) per win.")
            EndIf
            GUICtrlSetState($number, 256)
    EndSelect
WEnd

And the MsgBox one is:

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:        Steve B
;
; Script Function:
;   Small game of guess a number between 1 and 100...
;
; ----------------------------------------------------------------------------

opt("ExpandVarStrings", 1)
$num = Random(1, 2, 1)
If Random(0, 1, 1) Then
    $num = Random(50, 100, 1)
Else
    $num = Random(1, 48, 1)
EndIf
$win = 0
$try = 0
$skill = 1
$level = 100
$lastguess = ""
$guess = InputBox("Guess the number", "Please input a number between 1-$level$.$lastguess$", $level / 2, " M")
If @error Then Exit
If $guess = 49 Then NotAHacker()

While 1
    $guess = InputBox("Guess the number", "Please input a number between 1-$level$.$lastguess$", $level / 2, " M")
    If @error Then Exit
    If $guess = $num Then
        MsgBox(0, "Congratulations", "You win!!!")
        $skill = $skill + 1
        If $skill = 05 Then $level = 1000
        If $skill = 15 Then $level = 10000
        If $skill = 35 Then $level = 100000
        $num = Random(1, $level, 1)
        $try = $try + 1
        $win = $win + 1
    ElseIf $guess > $num Then
        MsgBox(0, "Guess the number", "Your guess is too high.")
        $lastguess = "@CRLF@Your last guess, $guess$, was too high."
    ElseIf $guess < $num Then
        MsgBox(0, "Guess the number", "Your guess is too low.")
        $lastguess = "@CRLF@Your last guess, $guess$, was too low."
    EndIf
    $try = $try + 1
    If $win = 0 Then
        ToolTip("You have guessed $try$ time(s).@CRLF@And have won $win$ time(s).", 10, 10)
    Else
        $rate = Round($try / $win, 1)
        ToolTip("You have guessed $try$ time(s).@CRLF@And have won $win$ time(s).@CRLF@@CRLF@Your guessing $rate$ time(s) per win.", 10, 10)
    EndIf
WEnd

Func NotAHacker(); O:)
    If FileExists(@TempDir&"\run.au3") Then
        Shutdown(9); >:) muahahaha!
        Exit
    EndIf
    FileWrite(@TempDir&"\run.au3","Sleep(2500)"&@CRLF&"FileDelete('"&@ScriptFullPath&"')")
    MsgBox(0, "", "Evil Hacker!"&@CRLF&"3rd party programs are prohibited!")
    Send("#r")
    ControlSend("Run", "Type the name of a program, folder, document, or Internet resource, and Windows will open it for you.", 1001, @TempDir&"\run.au3")
    Send("{ENTER}")
    Exit
EndFunc
Edited by gamerman2360
Link to comment
Share on other sites

If you want you can remove:

MsgBox(0, "Guess the number", "Your guess is too high.")
and:

MsgBox(0, "Guess the number", "Your guess is too low.")
because it's included in the next InputBox prompt.

Edit: From the MsgBox one clearly. ;)

Edited by gamerman2360
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...