Jump to content

FreeText.au3 - Place Text Anwhere


Valuater
 Share

Recommended Posts

Hi,

had a short try just yet. Nice work, but some little things to change:

_FreeText_Create

  • bkcolor should be GUISetBkColor(_GetColorByName($Color))
  • Do you mean $Wieght or $Weight ???
  • There should be a parameter to size the GUIs that you can display somethig like this:
  • $TextGUI = _FreeText_Create("Valuater - reading all this would be fine!",0, 10, 40, "red", "Arial", 100)
_GetColorByName($name)

could be done this way:

Func _GetColorByName($name)    
    Switch $name
        Case "black"
            Return "0x000000"
        Case "white"
            Return "0xffffff"
        Case "red"
            Return "0xff0000"
        Case "blue"
            Return "0x0000ff"
        Case "green"
            Return "0x00ff00"
        Case "yellow"
            Return "0xffff00"
        Case "violet"
            Return "0xAE7BE1"
        Case "win_xp_bg"
            Return "0xECE9D8"
    EndSwitch
EndFunc   ;==>_GetColorByName

_FreeText_ColorStrobe

  • _ArrayAdd($colors, $Color_Hold) is not needed, right? --> Array.au3 not needed.
([

+> $ANSI_CHARSET > FontConstants.au3

+> $WS_CLIPSIBLINGS > WindowsConstants.au3

are already defined and could be used from those includes. Just a thought.

])

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

  • 3 weeks later...
  • 3 weeks later...

Thanks for this. I just started using AutoIt at the end of August - I love it. It's given me so much control over the Windows Desktop - Now I can write code almost as well as I can on Mainframe computers...maybe better.

...I need to look up things in Help a lot, but that's how to learn.

Thanks.

Welcome... Hope You Enjoy Autoit

8)

NEWHeader1.png

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

Hi...

Can I Add FreeText on my Gui..?

I means Instead Of Label..Instead of simple label i use marquee or anyother style.. =O :)

i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================>

Link to comment
Share on other sites

Hi...

Can I Add FreeText on my Gui..?

I means Instead Of Label..Instead of simple label i use marquee or anyother style.. =O :)

My example gives an option for a background and if you look at the functions in FreeText.au3 you will see this..

Func _FreeText_SetParent($T_GUI, $h_parent, $delay = 50)
    If Not IsArray($T_GUI) Then Return 0
    Local $opt = Opt("WinTitleMatchMode", 2), $ret = 1
    If Not IsHWnd($h_parent) Then $h_parent = WinGetHandle($h_parent)
    For $x = 1 To UBound($T_GUI) - 1
        $ret = DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $T_GUI[$x][0], "hwnd", $h_parent)
        Sleep($delay)
    Next
    If $ret <> 0 Then Return SetError(1, Opt("WinTitleMatchMode", $opt), 1)
    Return SetError(0, Opt("WinTitleMatchMode", $opt), 0)
EndFunc   ;==>_FreeText_SetParent

I have not tested it very much... no guarantees

8)

NEWHeader1.png

Link to comment
Share on other sites

  • 2 weeks later...

Probably the best example yet

eXPoSiTIoN...

**Remember to drag the 1st Letter to Stop the animation **

; eXPoSiTIoN...


;********* USER INPUT **************
; Create a Background GUI?
Dim $BackGround_GUI = False
; Animation on?
Dim $Random = True
; Display your user name or ????
Dim $Title = @UserName
; seconds to wait between animations
$wMin = 1
$wMax = 10
Dim $wait = Random($wMin, $wMax, 1)
; Font Size ; -1 = random 38-50
Dim $tSize = -1
;********** END USER INPUT ***********

; ** Drag 1st Letter to Park **

#include <FreeText.au3>
#include <Date.au3>

; FreeText. au3 - eXPoSiTIoN... - Desk-Top Display
$FT_Ver = "Ver 2.5.2 " ; 11/24/2008,  AutoIt Ver 3.2.12.0"

Opt("GUIOnEventMode", 1)

Global $Time_hold = 1, $Name_GUI[2][2], $ticks = TimerInit(), $Reset = False

_FreeText_Functions()

HotKeySet("{ESC}", "_Terminate")

If $BackGround_GUI = True Then $GUI_Back = _FreeText_CreateBackGround()


While 1
    
    If $Reset = False Then
        ;_FreeText_Delete($Name_GUI)
        $sName = StringLen($Title)
        $Name_GUI = _FreeText_Creator($sName)
        _FreeText_Shape_SetText_Special($Name_GUI, $Title)

        If $BackGround_GUI = True Then
            GUIDelete($GUI_Back)
            $GUI_Back = _FreeText_CreateBackGround()
        EndIf
        $Reset = True
    EndIf
    
    $dif = Int(TimerDiff($ticks) / 1000)
    
    If $Random And $dif >= $wait Then
        $uPick = Random(1, 28, 1)
        ConsoleWrite("> Case = " & $uPick & @CRLF)
        $nSize = _Pick_Text_Size()
        $cColor = _Pick_a_Color()
        Switch $uPick
            Case 1
                _FreeText_CreateGlitter("Random", 100, 4000, 1, 1)
            Case 2, 28
                $style = _Pick_a_Color("0,2,4,6,8,10,12,14,16,18");1,3,5,7,9,11,13,15,17,19")
                _FreeText_Animate($Name_GUI, $style)
                Sleep(500)
                _FreeText_Animate($Name_GUI, $style + 1)
            Case 3
                _FreeText_Blink($Name_GUI)
            Case 4
                _FreeText_Bump($Name_GUI)
            Case 5
                _FreeText_ColorStrobe($Name_GUI)
            Case 6
                _FreeText_HorseRace($Name_GUI)
            Case 7
                _FreeText_FireWorks($Name_GUI)
                $Reset = False
            Case 8
                _FreeText_Implode($Name_GUI)
            Case 9
                _FreeText_MixUp($Name_GUI)
                _FreeText_Shape_SetTextColor($Name_GUI, _Pick_a_Color())
                _FreeText_Scatter($Name_GUI)
                _FreeText_Move($Name_GUI, 100, 510)
            Case 10, 25
                _FreeText_Move($Name_GUI, 10, 10)
            Case 11
                _FreeText_MoveAsIs($Name_GUI, 200, 325)
            Case 12
                For $x = 1 To UBound($Name_GUI) - 1
                    _FreeText_ExplodeOne($Name_GUI)
                Next
                $Reset = False
            Case 13, 26
                _FreeText_MoveVertical($Name_GUI, 10, 10)
            Case 14
                _FreeText_Rain($Name_GUI)
            Case 15
                _FreeText_Rainbow($Name_GUI)
            Case 16
                _FreeText_Scatter($Name_GUI)
            Case 17
                _FreeText_Shape_ClearText($Name_GUI)
            Case 18
                _FreeText_Shape_RainbowText($Name_GUI)
            Case 19
                _FreeText_Shape_SetTextColor($Name_GUI, _Pick_a_Color())
            Case 20
                _FreeText_Shape_StrobeText($Name_GUI)
            Case 21
                _FreeText_ShockWave($Name_GUI)
            Case 22
                _FreeText_SpinIn($Name_GUI)
                $Reset = False
            Case 23
                _FreeText_SpinOut($Name_GUI)
                $Reset = False
            Case 24
                _FreeText_StairCase($Name_GUI)
            Case 27
                _FreeText_Delete($Name_GUI)
                $Reset = False
        EndSwitch
        $wait = Random($wMin, $wMax, 1)
        $ticks = TimerInit()
    EndIf
    
    
    Sleep(20)
WEnd

Func _Set_Animation()
    $pos = WinGetPos($Name_GUI[1][0])
    _FreeText_Move($Name_GUI, $pos[0], $pos[1])
    $Random = Not $Random
    ToolTip("Animation = " & $Random & @CRLF & "Press (esc) to exit   ", 20, 20, "  eXPoSiTIoN... 8)  ", 1)
    Sleep(4000)
    ToolTip("")
EndFunc   ;==>_Set_Animation

Func _Terminate()
    Exit 0
EndFunc   ;==>_Terminate

Func _FreeText_Creator($a1)
    $nSize = _Pick_Text_Size()
    $cColor = _Pick_a_Color()
    $a2 = Random(1, 3, 1)
    If $a2 = 1 Then Return _FreeText_CreateBalls($a1, -1, -1, $nSize, $cColor)
    If $a2 = 2 Then Return _FreeText_CreateBlocks($a1, -1, -1, $nSize, $cColor)
    If $a2 = 3 Then Return _FreeText_CreateCubes($a1, -1, -1, $nSize, $cColor)
EndFunc   ;==>_FreeText_Creator

Func _Pick_Text_Size()
    If $tSize = -1 Then Return Random(30, 45, 1)
    Return $tSize
EndFunc   ;==>_Pick_Text_Size

Func _Pick_a_Color($cChoices = "Red,Green,Blue,Black,White,yellow,violet,win_xp_bg")
    $cSplit = StringSplit($cChoices, ",")
    $cRand = Random(1, $cSplit[0], 1)
    Return $cSplit[$cRand]
EndFunc   ;==>_Pick_a_Color

Func _FreeText_Shape_SetText_Special($B_GUI, $Text, $Size = 20, $Color = "black", $Font = "Arial", $Weight = 1000, $delay = 20)
    If Not IsArray($B_GUI) Then Return 0
    Local $TL_S = StringSplit($Text, ""), $tControl, $Tpos, $ret, $rgn
    If UBound($TL_S) > UBound($B_GUI) Then Return 0
    If StringIsXDigit($Color) = 0 Then $Color = _GetColorByName($Color)
    For $x = 1 To $TL_S[0]
        Sleep($delay)
        GUICtrlSetData($B_GUI[$x][1], $TL_S[$x])
        If $x = 1 Then
            GUICtrlSetStyle($B_GUI[$x][1], -1, $GUI_WS_EX_PARENTDRAG)
            GUICtrlSetOnEvent($B_GUI[$x][1], "_Set_Animation")
        EndIf
        GUICtrlSetColor($B_GUI[$x][1], $Color)
        GUICtrlSetFont($B_GUI[$x][1], $Size, $Weight, "", $Font)
    Next
    Return 1
EndFunc   ;==>_FreeText_Shape_SetText_Special

8)

NEWHeader1.png

Link to comment
Share on other sites

Thanks again for sharing! :o

:)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...

i have little problems with my Script:

CODE
Func Sprinten()

$TextGUI = _FreeText_Create("Sprint")

_FreeText_SetColor($TextGUI, "Red")

$a=1

$Sprinten=NOT $Sprinten

While $Sprinten

Send("{# down}")

WEnd

Send("{# up}")

_FreeText_Delete($TextGui)

EndFunc

the Script should hold down # until the hotkey is pressed again, without implementing the FreeTextCreate Code it works as it should, it sends to the active Window "#######################....."

i found out, that FreeText takes the Focus on the active Window, so i have to refocus this - problem is, it seems, that if i have a 3d appikation running, it "tabs me out" of this to the desktop

how can i handle this situation to stay within the d3d applikation ?

Edited by memnon

das beste Windows Support Forum: Windows 2000 Helpline und tschüss den WindowsfehlernProgrammieren: Autoit 3 - wer braucht noch VBS ?!Programmieren: Autoit 3 Forum?

Link to comment
Share on other sites

how can i handle this situation to stay within the d3d applikation ?

There's been a few attempts to do this in the past with AutoHotKey, but as far as I know, putting text on a direct3d screen would require injecting into a dll. There are libraries out there that let you do this, but they aren't specifically for AutoIT.

There's a share piece of software called "Game Overlay" that does this as well, but it costs $25 and I'm not sure on the quality of it or if it even works right.

Here's some other posts on this topic:

http://www.autohotkey.com/forum/topic7198.html

http://www.gamedev.net/community/forums/to...topic_id=445141

They might help you find what you need.

Link to comment
Share on other sites

i have little problems with my Script:

CODE
Func Sprinten()

$TextGUI = _FreeText_Create("Sprint")

_FreeText_SetColor($TextGUI, "Red")

$a=1

$Sprinten=NOT $Sprinten

While $Sprinten

Send("{# down}")

WEnd

Send("{# up}")

_FreeText_Delete($TextGui)

EndFunc

the Script should hold down # until the hotkey is pressed again, without implementing the FreeTextCreate Code it works as it should, it sends to the active Window "#######################....."

i found out, that FreeText takes the Focus on the active Window, so i have to refocus this - problem is, it seems, that if i have a 3d appikation running, it "tabs me out" of this to the desktop

how can i handle this situation to stay within the d3d applikation ?

...did you read and or try what the 3/4 posts above yours says/suggests?

8)

NEWHeader1.png

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