Jump to content

random refresh..?


Recommended Posts

I'm making a random phone number generator.

My code is:

#include <GUIConstants.au3>

$a = Random(0 , 9, 1)
$b = Random(0 , 9, 1)
$c = Random(0 , 9, 1)
$d = Random(0 , 9, 1)
$e = Random(0 , 9, 1)
$f = Random(0 , 9, 1)
$g = Random(0 , 9, 1)
$h = Random(0 , 9, 1)
$i = Random(0 , 9, 1)
$j = Random(0 , 9, 1)
$k = Random(0 , 9, 1)
$l = Random(0 , 9, 1)
$m = Random(0 , 9, 1)
$n = Random(0 , 9, 1)
$o = Random(0 , 9, 1)
$p = Random(0 , 9, 1)
$q = Random(0 , 9, 1)
$r = Random(0 , 9, 1)
$s = Random(0 , 9, 1)
$t = Random(0 , 9, 1)
$u = Random(0 , 9, 1)
$v = Random(0 , 9, 1)
$w = Random(0 , 9, 1)
$x = Random(0 , 9, 1)
$y = Random(0 , 9, 1)
$z = Random(0 , 9, 1)
$aa = Random(0 , 9, 1)
$ab = Random(0 , 9, 1)



GUICreate("Phone # Generator", 162, 190, 380, 184)
$Label1 = GUICtrlCreateLabel("***-" & $a & $b & $c & "-" & $d & $e & $f & $g, 48, 21, 66, 21, $SS_CENTER)
$Label2 = GUICtrlCreateLabel("***-" & $h & $i & $j & "-" & $k & $l & $m & $n, 48, 53, 66, 21, $SS_CENTER)
$Label3 = GUICtrlCreateLabel("***-" & $o & $p & $q & "-" & $r & $s & $t & $u, 48, 85, 66, 21, $SS_CENTER)
$Label4 = GUICtrlCreateLabel("***-" & $v & $w & $x & "-" & $y & $z & $aa & $ab, 48, 117, 66, 21, $SS_CENTER)
$Button1 = GUICtrlCreateButton("refresh", 48, 160, 66, 21, 0)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
Wend

can anyone help me make the refresh button make new numbers? and improve my code?

Link to comment
Share on other sites

Try this...

#include <GUIConstants.au3>
Global $a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $L, $m, $n, $o, $p, $q, $r, $s, $t, $u, $v, $w, $x, $y, $z, $aa, $ab
GUICreate("Phone # Generator", 162, 190, 380, 184)
$Label1 = GUICtrlCreateLabel("***-" & $a & $b & $c & "-" & $d & $e & $f & $g, 48, 21, 66, 21, $SS_CENTER)
$Label2 = GUICtrlCreateLabel("***-" & $h & $i & $j & "-" & $k & $L & $m & $n, 48, 53, 66, 21, $SS_CENTER)
$Label3 = GUICtrlCreateLabel("***-" & $o & $p & $q & "-" & $r & $s & $t & $u, 48, 85, 66, 21, $SS_CENTER)
$Label4 = GUICtrlCreateLabel("***-" & $v & $w & $x & "-" & $y & $z & $aa & $ab, 48, 117, 66, 21, $SS_CENTER)
$Button1 = GUICtrlCreateButton("refresh", 48, 160, 66, 21, 0)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Button1
            _Refresh()
            GUICtrlSetData($Label1, "***-" & $a & $b & $c & "-" & $d & $e & $f & $g)
            GUICtrlSetData($Label2, "***-" & $h & $i & $j & "-" & $k & $L & $m & $n)
            GUICtrlSetData($Label3, "***-" & $o & $p & $q & "-" & $r & $s & $t & $u)
            GUICtrlSetData($Label4, "***-" & $v & $w & $x & "-" & $y & $z & $aa & $ab)
    EndSelect
WEnd
Func _Refresh()
    $a = Random(0, 9, 1)
    $b = Random(0, 9, 1)
    $c = Random(0, 9, 1)
    $d = Random(0, 9, 1)
    $e = Random(0, 9, 1)
    $f = Random(0, 9, 1)
    $g = Random(0, 9, 1)
    $h = Random(0, 9, 1)
    $i = Random(0, 9, 1)
    $j = Random(0, 9, 1)
    $k = Random(0, 9, 1)
    $L = Random(0, 9, 1)
    $m = Random(0, 9, 1)
    $n = Random(0, 9, 1)
    $o = Random(0, 9, 1)
    $p = Random(0, 9, 1)
    $q = Random(0, 9, 1)
    $r = Random(0, 9, 1)
    $s = Random(0, 9, 1)
    $t = Random(0, 9, 1)
    $u = Random(0, 9, 1)
    $v = Random(0, 9, 1)
    $w = Random(0, 9, 1)
    $x = Random(0, 9, 1)
    $y = Random(0, 9, 1)
    $z = Random(0, 9, 1)
    $aa = Random(0, 9, 1)
    $ab = Random(0, 9, 1)
EndFunc   ;==>_Refresh

Personally i found this useless due to two reasons, you may need to pay to get a phone number of your choice, these number may not in their list of availabilitys.

Link to comment
Share on other sites

Try this...

#include <GUIConstants.au3>
Global $a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $L, $m, $n, $o, $p, $q, $r, $s, $t, $u, $v, $w, $x, $y, $z, $aa, $ab
GUICreate("Phone # Generator", 162, 190, 380, 184)
$Label1 = GUICtrlCreateLabel("***-" & $a & $b & $c & "-" & $d & $e & $f & $g, 48, 21, 66, 21, $SS_CENTER)
$Label2 = GUICtrlCreateLabel("***-" & $h & $i & $j & "-" & $k & $L & $m & $n, 48, 53, 66, 21, $SS_CENTER)
$Label3 = GUICtrlCreateLabel("***-" & $o & $p & $q & "-" & $r & $s & $t & $u, 48, 85, 66, 21, $SS_CENTER)
$Label4 = GUICtrlCreateLabel("***-" & $v & $w & $x & "-" & $y & $z & $aa & $ab, 48, 117, 66, 21, $SS_CENTER)
$Button1 = GUICtrlCreateButton("refresh", 48, 160, 66, 21, 0)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Button1
            _Refresh()
            GUICtrlSetData($Label1, "***-" & $a & $b & $c & "-" & $d & $e & $f & $g)
            GUICtrlSetData($Label2, "***-" & $h & $i & $j & "-" & $k & $L & $m & $n)
            GUICtrlSetData($Label3, "***-" & $o & $p & $q & "-" & $r & $s & $t & $u)
            GUICtrlSetData($Label4, "***-" & $v & $w & $x & "-" & $y & $z & $aa & $ab)
    EndSelect
WEnd
Func _Refresh()
    $a = Random(0, 9, 1)
    $b = Random(0, 9, 1)
    $c = Random(0, 9, 1)
    $d = Random(0, 9, 1)
    $e = Random(0, 9, 1)
    $f = Random(0, 9, 1)
    $g = Random(0, 9, 1)
    $h = Random(0, 9, 1)
    $i = Random(0, 9, 1)
    $j = Random(0, 9, 1)
    $k = Random(0, 9, 1)
    $L = Random(0, 9, 1)
    $m = Random(0, 9, 1)
    $n = Random(0, 9, 1)
    $o = Random(0, 9, 1)
    $p = Random(0, 9, 1)
    $q = Random(0, 9, 1)
    $r = Random(0, 9, 1)
    $s = Random(0, 9, 1)
    $t = Random(0, 9, 1)
    $u = Random(0, 9, 1)
    $v = Random(0, 9, 1)
    $w = Random(0, 9, 1)
    $x = Random(0, 9, 1)
    $y = Random(0, 9, 1)
    $z = Random(0, 9, 1)
    $aa = Random(0, 9, 1)
    $ab = Random(0, 9, 1)
EndFunc   ;==>_Refresh

Personally i found this useless due to two reasons, you may need to pay to get a phone number of your choice, these number may not in their list of availabilitys.

no.. not for me. to prank call.
Link to comment
Share on other sites

Hi,

#include <GUIConstants.au3>
#include <String.au3>

Global $nr[4]
Global $Label[4]

GUICreate("Phone # Generator", 162, 190, 380, 184)
$Label[0] = GUICtrlCreateLabel('', 48, 21, 66, 21, $SS_CENTER)
$Label[1] = GUICtrlCreateLabel('', 48, 53, 66, 21, $SS_CENTER)
$Label[2] = GUICtrlCreateLabel('', 48, 85, 66, 21, $SS_CENTER)
$Label[3] = GUICtrlCreateLabel('', 48, 117, 66, 21, $SS_CENTER)
$refresh_B = GUICtrlCreateButton("refresh", 48, 160, 66, 21, 0)
GUISetState(@SW_SHOW)

_getNumbers()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $refresh_B
            _getNumbers()
    EndSelect
WEnd

Func _getNumbers()
    For $i = 0 To UBound($nr) - 1
        $nr[$i] = ''
        For $y = 0 To 7
            $nr[$i] &= Random(0, 9, 1)
        Next
        GUICtrlSetData($Label[$i], _StringInsert(_StringInsert($nr[$i], '-', 3), '***-', 0))
    Next
EndFunc  ;==>_getNumbers

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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