Sign in to follow this  
Followers 0
ChrisL

Can you use the DEC values for letters?

6 posts in this topic

#1 ·  Posted (edited)

In the help file for Ascii characters there is a column with DEC

Char Dec Hex Description

32 20 Space

! 33 21 Exclamation mark

" 34 22 Quotation mark (" in HTML)

# 35 23 Cross hatch (number sign)

$ 36 24 Dollar sign

etc

What I was looking to do was the create random letters and symbols and I thought that the DEC values in the help file are just numerical, so if I created a random number between 32 and 125 then this would give me a random letter/symbol

So can you use the DEC values and turn the back in to Characters.

I'm sure you can I just cant see it!

Edited by ChrisL

Share this post


Link to post
Share on other sites



like this

While 1
    
    $Num = Random(32, 125, 1)
    
    MsgBox(0,"letter/character", Chr($num))
    
WEnd

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

like this

While 1
    
    $Num = Random(32, 125, 1)
    
    MsgBox(0,"letter/character", Chr($num))
    
WEnd

8)

Yep thats it

Chr() was what I was looking for but I just couldn't see it!!

Thanks :P

Share this post


Link to post
Share on other sites

Glad i could help

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

It works cool..

Its a screensaver for a multi-training bay program where one of our trainers can select the customer they are training.

Problem was that the machine can not run a normal screen saver and I only wanted one to run while the login and customer choice was active.

All it does is randomly generate a string across a black screen which says "All your bays are belong to us" but puts up random charaters before settling on the correct one.

Just thought I should post up what it was all for and say thanks again..

$Running = 0
$Mouse1 = MouseGetPos()
$Count = 1
; Script generated by AutoBuilder 0.5 Prototype
#NoTrayIcon
#include <GuiConstants.au3>
$Login = WinWait ("X-Bay")


If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

$gui = GuiCreate("XbayScr", 800, 600,(@DesktopWidth-800)/2, (@DesktopHeight-600)/2 , $WS_POPUP + $WS_SYSMENU + $WS_MINIMIZEBOX)
GUISetBkColor("0x000000")

$Text = GuiCtrlCreateLabel("", 50, 120, 600, 40 )
GUICtrlSetFont ($Text, 300 , 800 , "" , "Tahoma" )
GUICtrlSetColor($Text, "0xFFFFFF")

#endregion --- GuiBuilder generated code End ---

While $Login = 1
$Mouse2 = MouseGetPos()

if $mouse1[0] = $Mouse2[0] and $Mouse1[1] = $Mouse2[1] and $running = 0 Then
    $timer = TimerInit ( )
    $Running = 1
    


Endif

If $mouse1[0] <> $Mouse2[0] or $Mouse1[1] <> $Mouse2[1] Then
    $mouse1[0] = $mouse2[0]
    $Mouse1[1] = $Mouse2[1]
    $running = 0
    $Count = 1
    
    $timer = TimerInit ( )
    if WinActive ($gui) then
        GuiSetState(@SW_HIDE,$gui)
        WinSetOnTop($Gui,"",0)
        Endif
    Endif

$TimerDiff = TimerDiff ( $timer )

If $timerDiff > 1000000 and $Mouse1[0] = $Mouse2[0] and $Mouse1[1] = $Mouse2[1] Then  ; 10 mins = 1000000
    $Mouse2 = MouseGetPos()
    
    Switch $Count
Case 1
    GUICtrlSetPos ( $Text, Random(10, 400, 1), Random(10, 500, 1),400, 40)
    GUICtrlSetFont ($Text, 20 , 400 , "", "Tahoma" )
    $string =""
    
Case 2
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "A"
    GUICtrlSetData ($Text, $String)

    
Case 3
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "l"
    GUICtrlSetData ($Text, $String)
    
Case 4
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "l"
    GUICtrlSetData ($Text, $String)
    
Case 5
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & " "
    GUICtrlSetData ($Text, $String)
    
Case 6
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "y"
    GUICtrlSetData ($Text, $String)
    
Case 7
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "o"
    GUICtrlSetData ($Text, $String)
    
Case 8
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "u"
    GUICtrlSetData ($Text, $String)
    
Case 9
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "r"
    GUICtrlSetData ($Text, $String)
    
Case 10
    $String = $String & " "
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "b"
    GUICtrlSetData ($Text, $String)
    
Case 11
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
        next
    GUICtrlSetData ($Text, $String)
    
Case 12
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "a"
    GUICtrlSetData ($Text, $String)
    
Case 13
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "y"
    GUICtrlSetData ($Text, $String)
    
Case 14
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "s"
    GUICtrlSetData ($Text, $String)
    
Case 15
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & " "
    GUICtrlSetData ($Text, $String)
    
Case 16
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "a"
    GUICtrlSetData ($Text, $String)
    
Case 17
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "r"
    GUICtrlSetData ($Text, $String)
    
Case 18
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "e"
    GUICtrlSetData ($Text, $String)
    
Case 19
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & " "
    GUICtrlSetData ($Text, $String)
    
Case 20
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "b"
    GUICtrlSetData ($Text, $String)
    
Case 21
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "e"
    GUICtrlSetData ($Text, $String)
    
Case 22
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "l"
    GUICtrlSetData ($Text, $String)
    
Case 23
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "o"
    GUICtrlSetData ($Text, $String)
    
Case 24
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "n"
    GUICtrlSetData ($Text, $String)
    
Case 25
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "g"
    GUICtrlSetData ($Text, $String)
    
Case 26
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & " "
    GUICtrlSetData ($Text, $String)
    
Case 27
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "t"
    GUICtrlSetData ($Text, $String)
    
Case 28
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "o"
    GUICtrlSetData ($Text, $String)
    
Case 29
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & " "
    GUICtrlSetData ($Text, $String)
    
Case 30
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "u"
    GUICtrlSetData ($Text, $String)
    
Case 31
    
        For $i = 1 to 10
        GUICtrlSetData ($Text, $String &randomChr())
        sleep (100)
    next
    $String = $String & "s"
    GUICtrlSetData ($Text, $String)
    Sleep (500)
    
Case 32
    GUICtrlSetData ($Text,  "")
    GUICtrlSetPos ( $Text, 200, 120, 690, 370)
    GUICtrlSetFont ($Text, 100 , 800 , 2 , "Tahoma" )
    GUICtrlSetData ($Text,  "X-Bay")
    Sleep(1000)
Case Else
    $Count = 0
EndSwitch
    $Count = $count + 1
    if not WinActive ($gui) then
        GuiSetState(@SW_SHOW,$gui)
        WinSetOnTop($Gui,"",1)
        Endif
    Endif
Sleep(10)
$Login = WinExists ("X-Bay")

    Wend


Func RandomChr()
    
    $Num = Random(32, 125, 1)
    
    Return Chr($num)
    
EndFunc

Share this post


Link to post
Share on other sites

Looks good

you should post this in the.... Scripts and Scraps section also

8)


NEWHeader1.png

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