Jump to content

Show text message over .cdg video


Belini
 Share

Recommended Posts

I'm trying to display text messages on top of .cdg video but the text message is flashing all the time and this only happens in .cdg files I've tried all the ways I know but I couldn't solve it, does anyone know how to solve this problem?

Video showing the problem

 

Files needed for testing:  https://mega.nz/file/VJllySaI#r5KCIaR_h2dr0Eol0M24Nccr8Bj7v5fnOLGtdq0svmc

 

Link to comment
Share on other sites

After a lot of searching and many tests I found a code posted by @death pax that can display a text message over .cdg without flashing but I couldn't make the text stay centered on the screen the text is always displayed starting from left, I need help to center the text regardless of the length of the text

Code posted by death pax

; ----------------------------------------------------------------------------
; Crosshair Overlay
; AutoIt Version: 3.1.1
; Author:        Death Pax <death_pax@msn.com
;
; Script Function:
;   Generates a crosshair overlay
;
; ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <GUIConstants.au3>
#include <WindowsConstants.au3>

opt("traymenumode",1)
$aboutitem = TrayCreateItem("About")
$Exititem   = TrayCreateItem("Exit")
$gui = GUICreate("Window",@DesktopWidth,200,-1,-1,$WS_POPUP,BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetState(@SW_SHOW)
UpdateTextWindow($gui,"TEXT OVERLAY SCREEN WITH CDG VIDEO",@DesktopWidth,50,"ARIAL BLACK",1,@DesktopWidth/2-17,@DesktopHeight/2,0xFF0000)
While 1
$msg = TrayGetMsg()
    Select
        Case $msg = $aboutitem
            Msgbox(64,"About:","Crosshair v1 "&@CRLF&"Created by Death Pax")
        Case $msg = $exititem
            Exit
        EndSelect
    winsetstate($gui,"",@SW_DISABLE)
            GuiSetCursor(16,1,$gui)
Wend
Func UpdateTextWindow($hwnd,$zText,$width,$height,$font="Lucida Sans Unicode",$weight=1, $x=-1,$y=-1,$color=-1)
    Local Const $ANSI_CHARSET = 0
    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 $font = "" Then $font = "Microsoft Sans Serif"
    If $weight = -1 Then $weight = 1000

    If $color <> -1 Then
        GUISetBkColor($color,$hwnd)
    Else
        GUISetBkColor(0xFF0000,$hwnd)
    EndIf
    Local $hDC= DLLCall("user32.dll","int","GetDC","hwnd",$hwnd)
    Local $hMyFont = DLLCall("gdi32.dll","hwnd","CreateFont","int",$height, _
                    "int",0,"int",0,"int",0,"int",1000,"int",0, _
                    "int",0,"int",0,"int",$ANSI_CHARSET, _
                    "int",$OUT_CHARACTER_PRECIS,"int",$CLIP_DEFAULT_PRECIS, _
                    "int",$PROOF_QUALITY,"int",$FIXED_PITCH,"str",$font )
    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",$zText,"int",StringLen($zText))
    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",$hwnd,"int",$hDC[0])
    DLLCall("user32.dll","int","SetWindowRgn","hwnd",$hwnd,"hwnd",$hRgn2[0],"int",1)
    DLLCall("gdi32.dll","int","SelectObject","int",$hDC[0],"hwnd",$hOldFont[0])
EndFunc

 

Link to comment
Share on other sites

#include <GUIConstants.au3>
#include <WinApi.au3>
#include <array.au3>
#include <WindowsConstants.au3>
Opt("traymenumode", 1)
$aboutitem = TrayCreateItem("About")
$Exititem = TrayCreateItem("Exit")
$gui = GUICreate("Window", @DesktopWidth, @DesktopHeight, -1, -1, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetState(@SW_SHOW)
$gui2 = GUICreate("Window", @DesktopWidth, @DesktopHeight, -1, -1, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetState(@SW_SHOW)
$gui3 = GUICreate("Window", @DesktopWidth, @DesktopHeight, -1, -1, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetState(@SW_SHOW)
$x = @DesktopWidth / 2
$y = @DesktopHeight / 2 - 60
UpdateTextWindow($gui, "TEXT OVERLAY SCREEN WITH CDG VIDEO and much more text until the dekstop ends :D", 15, 50, "ARIAL BLACK", 1, $x, $y, 0xFF0000)
UpdateTextWindow($gui2, "For using second line you have to call it again with another GUI i guess :/ ", 15, 50, "ARIAL BLACK", 1, $x, $y+50, 0xFF0000)
UpdateTextWindow($gui3, "else you would have to adjust the SetWindowRgn call through the next call", 15, 50, "ARIAL BLACK", 1, $x, $y+100, 0xFF0000)
While 1
    $msg = TrayGetMsg()
    Select
        Case $msg = $aboutitem
            MsgBox(64, "About:", "Crosshair v1 " & @CRLF & "Created by Death Pax")
        Case $msg = $Exititem
            Exit
    EndSelect
    WinSetState($gui, "", @SW_DISABLE)
    GUISetCursor(16, 1, $gui)
WEnd
Func UpdateTextWindow($hwnd, $zText, $width, $height, $font = "Lucida Sans Unicode", $weight = 0, $x = 0, $y = 0, $color = -1)
    Local Const $ANSI_CHARSET = 0
    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 $font = "" Then $font = "Microsoft Sans Serif"
    If $weight = -1 Then $weight = 1000

    If $color <> -1 Then
        GUISetBkColor($color, $hwnd)
    Else
        GUISetBkColor(0xFF0000, $hwnd)
    EndIf
    Local $hDC = DllCall("user32.dll", "int", "GetDC", "hwnd", $hwnd)
    Local $hMyFont = DllCall("gdi32.dll", "hwnd", "CreateFont", "int", $height, _
            "int", $width, "int", 0, "int", 0, "int", 1000, "int", 0, _
            "int", 0, "int", 0, "int", $ANSI_CHARSET, _
            "int", $OUT_CHARACTER_PRECIS, "int", $CLIP_DEFAULT_PRECIS, _
            "int", $PROOF_QUALITY, "int", $FIXED_PITCH, "str", $font)
    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", $zText, "int", StringLen($zText))
    DllCall("gdi32.dll", "int", "EndPath", "int", $hDC[0])
    Local $hRgn1 = DllCall("gdi32.dll", "hwnd", "PathToRegion", "int", $hDC[0])
    Local $rc2 = DllStructCreate("int Left;int Top;int Right;int Bottom")
    DllCall("gdi32.dll", "int", "GetRgnBox", "hwnd", $hRgn1[0], _
            "ptr", DllStructGetPtr($rc2))
    Local $hRgn2 = DllCall("gdi32.dll", "hwnd", "CreateRectRgnIndirect", _
            "ptr", DllStructGetPtr($rc2))
    Local $x_rgn = StringRegExp(DllStructGetData($rc2, 'Right'), "^([-+]?)0*(\d+)$", 1)
    Local $y_rgn = StringRegExp(DllStructGetData($rc2, 'Left'), "^([-+]?)0*(\d+)$", 1)
    Local $t = StringRegExp(DllStructGetData($rc2, 'Top'), "^([-+]?)0*(\d+)$", 1)
    Local $b = StringRegExp(DllStructGetData($rc2, 'Bottom'), "^([-+]?)0*(\d+)$", 1)
    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('gdi32.dll', 'int', 'OffsetRgn', 'handle', $hRgn2[0], 'int', $x - (($x_rgn[1] - $y_rgn[1]) / 2), 'int', $y - (($t[1]-$b[1])/2))
    DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hwnd, "int", $hDC[0])
    DllCall("user32.dll", "int", "SetWindowRgn", "hwnd", $hwnd, "hwnd", $hRgn2[0], "int", 1)
    DllCall("gdi32.dll", "int", "SelectObject", "int", $hDC[0], "hwnd", $hOldFont[0])

EndFunc   ;==>UpdateTextWindow

Here you go.

Actually not tested with your cdg, but you can move it like this everywhere on screen :) 

 

 

EDIT: updated there was a bug with the $width

Edited by Aelc

why do i get garbage when i buy garbage bags? <_<

Link to comment
Share on other sites

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