Jump to content

how can i display text on the screen?


Guest
 Share

Recommended Posts

Try this:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
HotKeySet("{ESC}", "Terminate")
$txt = "I'm Nessie a giant lake monster"



MainGUI()

While 1
    Sleep(500)
WEnd

Func MainGUI()
    _TransparentTextWindow("MyTextGUI", $txt, 390, 30, @DesktopWidth-390, @DesktopHeight-70, "Arial", 1000, 0x00FF00, -1, -1, -1, 1, false)
    If @error Then
        MsgBox(262160, "ERROR", "Unable to create window - check parameters")
        Exit
    EndIf
    GUISetState(@SW_SHOW)
EndFunc

Func Terminate()
    Exit
EndFunc

Func _TransparentTextWindow($h_WinTitle, $s_WinText, $i_WinWidth, $i_WinHeight, $i_WinXPosn = -1, $i_WinYPosn = -1, _
        $s_TextFont = -1, $i_FontWeight = -1, $v_FontColor = -1, $i_FontItalics = 0, $i_FontUnderline = 0, $i_FontStrikeOut = 0, $i_Taskbar = 0, $i_WinExist = False, $i_hwnd = 0)
    Local Const $DEFAULT_CHARSET = 0 ; ANSI character set
    Local Const $OUT_CHARACTER_PRECIS = 2
    Local Const $CLIP_DEFAULT_PRECIS = 0
    Local Const $PROOF_QUALITY = 2
    Local Const $FIXED_PITCH = 1
    Local Const $RGN_XOR = 3
    If $h_WinTitle = "" Then $h_WinTitle = "AutoIt Overlayed Window"
    If $s_WinText = "" Then $s_WinText = "|"
    If $i_WinWidth < 1 Or $i_WinWidth > @DesktopWidth Then SetError(1) ; window width outside current screen geometry
    If $i_WinHeight < 1 Or $i_WinHeight > @DesktopHeight Then SetError(1) ; window height outside current screen geometry
    If $i_WinXPosn = -1 Then $i_WinXPosn = (@DesktopWidth / 2) - ($i_WinWidth / 2) ; center the window horizontally
    If $i_WinYPosn = -1 Then $i_WinYPosn = (@DesktopHeight / 2) - ($i_WinHeight / 2) ; center the window vertically
    If $i_WinXPosn < 1 Or $i_WinXPosn > (@DesktopWidth - $i_WinWidth) Then SetError(1) ; window won't fit on current screen geometry
    If $i_WinYPosn < 1 Or $i_WinYPosn > (@DesktopHeight - $i_WinHeight) Then SetError(1) ; window won't fit on current screen geometry
    If @error Then Return ; return with @error = 1
    If $s_TextFont = "" Or $s_TextFont = -1 Then $s_TextFont = "Microsoft Sans Serif" ; default font
    If $i_FontWeight = "" Or $i_FontWeight = -1 Then $i_FontWeight = 450 ; default Font weight
    If $v_FontColor = "" Or $v_FontColor = -1 Then $v_FontColor = "0xFF0000" ; default font colour (red)
    If $i_FontItalics <> 1 Then $i_FontItalics = 0 ; no italics as default
    If $i_FontUnderline <> 1 Then $i_FontUnderline = 0 ; no underlining as default
    If $i_FontStrikeOut <> 1 Then $i_FontStrikeOut = 0 ; no strike out font as default
    If $i_Taskbar <> 1 Then ; display tray icon
        if $i_WinExist = False Then
            Local $h_GUI = GUICreate($h_WinTitle, $i_WinWidth, $i_WinHeight, $i_WinXPosn, _
                $i_WinYPosn, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
        Else
            Local $h_GUI = WinGetHandle($i_hwnd)
        EndIf
    Else ; hide tray icon
        if $i_WinExist = False Then
            Local $h_GUI = GUICreate($h_WinTitle, $i_WinWidth, $i_WinHeight, $i_WinXPosn, _
                $i_WinYPosn, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
        Else
            Local $h_GUI = WinGetHandle($i_hwnd)
        EndIf
    EndIf
    GUISetBkColor($v_FontColor)
    Local $hDC = DllCall("user32.dll", "int", "GetDC", "hwnd", $h_GUI)
    Local $hMyFont = DllCall("gdi32.dll", "hwnd", "CreateFont", "int", $i_WinHeight, _
            "int", 0, "int", 0, "int", 0, "int", $i_FontWeight, "int", $i_FontItalics, _
            "int", $i_FontUnderline, "int", $i_FontStrikeOut, "int", $DEFAULT_CHARSET, _
            "int", $OUT_CHARACTER_PRECIS, "int", $CLIP_DEFAULT_PRECIS, _
            "int", $PROOF_QUALITY, "int", $FIXED_PITCH, "str", $s_TextFont)
    Local $hOldFont = DllCall("gdi32.dll", "hwnd", "SelectObject", "int", $hDC[0], _
            "hwnd", $hMyFont[0])
    DllCall("gdi32.dll", "int", "BeginPath", "int", $hDC[0])
    DllCall("gdi32.dll", "int", "TextOut", "int", $hDC[0], "int", 0, "int", 0, _
            "str", $s_WinText, "int", StringLen($s_WinText))
    DllCall("gdi32.dll", "int", "EndPath", "int", $hDC[0])
    Local $hRgn1 = DllCall("gdi32.dll", "hwnd", "PathToRegion", "int", $hDC[0])
    Local $rc = DllStructCreate("int;int;int;int")
    DllCall("gdi32.dll", "int", "GetRgnBox", "hwnd", $hRgn1[0], _
            "ptr", DllStructGetPtr($rc))
    Local $hRgn2 = DllCall("gdi32.dll", "hwnd", "CreateRectRgnIndirect", _
            "ptr", DllStructGetPtr($rc))
    DllCall("gdi32.dll", "int", "CombineRgn", "hwnd", $hRgn2[0], "hwnd", $hRgn2[0], _
            "hwnd", $hRgn1[0], "int", $RGN_XOR)
    DllCall("gdi32.dll", "int", "DeleteObject", "hwnd", $hRgn1[0])
    DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $h_GUI, "int", $hDC[0])
    DllCall("user32.dll", "int", "SetWindowRgn", "hwnd", $h_GUI, "hwnd", $hRgn2[0], "int", 1)
    DllCall("", "int", "SelectObject", "int", $hDC[0], "hwnd", $hOldFont[0])
    Return $h_GUI
EndFunc ;==>_TransparentTextWindow

Hi!

My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Link to comment
Share on other sites

Give it a try, this one is simple :

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>

Local $hGUI = 0, $hGraphics = 0, $hBrush = 0, $hFormat = 0, $hFamily = 0, $hFont = 0, $tLayout = 0

#region GUI
$hGUI = GUICreate("MyGUI", 250, 50, -1, -1, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED))
GUISetBkColor(0x000000)

_WinAPI_SetLayeredWindowAttributes($hGUI, 0x000000)
GUISetState(@SW_SHOW, $hGUI)
#endregion

#region Draw
_GDIPlus_Startup()

$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)

$hBrush = _GDIPlus_BrushCreateSolid(0xFF00FF00)

$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, 17, 1)
$tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)

_GDIPlus_GraphicsDrawStringEx($hGraphics, "Volume: 76%", $hFont, $tLayout, $hFormat, $hBrush)

For $iBar = 0 To 13
_GDIPlus_GraphicsFillRect($hGraphics, 150 + $iBar * 7, 0, 3, 25, $hBrush)
Next
#endregion

While GUIGetMsg() <> $GUI_EVENT_CLOSE
Sleep(1000)
WEnd

#region Release ressources
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)

_GDIPlus_BrushDispose($hBrush)

_GDIPlus_GraphicsDispose($hGraphics)

_GDIPlus_Shutdown()

GUIDelete($hGUI)
#endregion

Br, FireFox.

Link to comment
Share on other sites

thanks!!

i have modified the function _TransparentTextWindow()

and i added at the end of the function the line:

GUISetState(@SW_SHOW)

before

Return $h_GUI

so now i can call the function Directly without MainGUI().

i don't know why the author of the function didn't do it.

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