Jump to content

Random Function


Joke758
 Share

Recommended Posts

I just made a function for fun with the ie.au3.

Requirements:

AutoIt3 Beta with COM support (post 3.1.1) and IE.net

Thanks to random.org.

This is a bit useless but I made this for fun and for testing ie.au3 only ^^.

;By Joke758

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  Use the _Random function to generate a true random number   ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#include <GUIConstants.au3>
#include <ie.au3>
$Form2 = GUICreate("Yes\No question asker", 375, 165, 251, 158)
GUISetBkColor(0x008080)
GUICtrlCreateLabel("Yes\No question asker", 80, 16, 215, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Small Fonts")
GUICtrlSetColor(-1, 0x000080)
GUICtrlSetBkColor(-1, 0x008080)
$Button1 = GUICtrlCreateButton("Ask", 144, 128, 75, 25)
$Input1 = GUICtrlCreateInput("", 56, 96, 249, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlCreateLabel("Ask your question here:", 128, 72, 115, 17)
GUICtrlSetBkColor(-1, 0x008080)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
    EndSelect
;;;;;;;;;;
If $msg = $button1 and GUICTRLREAD ( $input1 ) = "" Then
    MsgBox ( 16, "Error", "Please ask a question" )
EndIf

If $msg = $button1 and GUICTRLREAD ( $input1 ) <> "" Then
    $a = _Random (1,2)
    If $a = 1 Then
    GuiCtrlSetData ( $input1, "Yes" )
    EndIf
    
    If $a = 2 Then
    GuiCtrlSetData ( $input1, "No" )
EndIf
EndIf
;;;;;;;;;;
WEnd
Exit








;===============================================================================
;
; Function Name:    _Random($value1,$value2)
; Description:      Return a true random number using www.random.org, using atmospheric noise.
; Parameter(s):     $value1         The smallest value ( -1000000000 is the minimum )
;                   $value2         The largest value ( 1000000000 is the maximum )

; Requirement(s):   AutoIt3 Beta with COM support (post 3.1.1) and IE.net
; Return Value(s):  On Success - Returns a true random number
;                   On Failure - Returns 0 and sets @ERROR = 1
; Author(s):        Joke758
;
;===============================================================================
;
Func _Random($value1,$value2)
    
    If $value1 < -1000000000 Then
        SetError( 1 )
        Return 0
    EndIf
    
    If $value2 > 1000000000 Then
        SetError( 1 )
        Return 0
    EndIf

$oIE = _IECreate("http://random.org/cgi-bin/randnum?num=1&min=" & $value1 & "&max=" & $value2 & "&col=1",0, 0)
$randomz0r = _IEBodyReadText($oIE)
Return $randomz0r
Endfunc ;==> _Random

:">

Edited by Joke758

[u]My Programs:[/u]Word Search Creator - Make your own Word SearchShortHand - Hide a secret message in a jpg fileHex Editor - Edit your Binary fileIncrease file size - Increase the size of any filesArt Generator - A program that generate random picture[u]My Functions:[/u]16-Bits Hash - My Hash function similar to MD5Probabilities - My probabilities function (factorial, permuation, combination)_GetDate() - Convert a date to a day of the week_Base(), _Dec() - Convert a number in any base (bin, oct, hex, dec). Create your own!

Link to comment
Share on other sites

This is nice! It's very quick as well.

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

_INetGetSource() should do what you need and it should take up less time then ie.au3 (or at the verry least consume less memory)

but if this was only for trying out ie.au3 id say good job :D

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

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