Jump to content
Sign in to follow this  
cramaboule

Text over movie

Recommended Posts

Hi all,

 

I was wondering if it is possible (and how) to put text on video on-the-fly (like VLC displays Title movie at the begining)

and of course doing that in AutoIt

Thanks in advance...

 

C.

Share this post


Link to post
Share on other sites

I think that may be problematic, because a video constantly "repaints" a certain area, at least that's the way i think about it, but there's a possibility that creating a window with certain flags can ensure that it stays over everything else, and unaffected.

See this example:

#include <FileConstants.au3>
#include <WinAPIFiles.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
;#include <WinAPISysWin.au3>

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode

; #FUNCTION# ====================================================================================================================
; Name ..........: OverlayWindow
; Description ...:  Throws up a child window with transparent background over current window
;
; Parameters :
;   $hwndParent         parent hwnd
;   $rectToHighlight    rect to draw (or if null, skip)
;   $rectForText    rect for textToWrite
;   $textToWrite    the text to write
; ===============================================================================================================================
Func OverlayWindow($hwndParent, $rectToHighlight, $rectForText, $textToWrite)

   $style = BitOR($WS_CHILD, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS)
   $exstyle = BitOR($WS_EX_TOPMOST, $WS_EX_COMPOSITED, $WS_EX_TRANSPARENT)

   $hGUI = GUICreate("transparent overlay", -1, -1, -1, -1, $style, $exstyle)

    GUISetBkColor(0xFFFFFF)
  _WinAPI_SetLayeredWindowAttributes($hGUI, 0xFFFFFF, 0, $LWA_COLORKEY)

   ConsoleWrite("**** $hGUI: " & $hGUI & @CRLF)
   ConsoleWrite("**** @error: " & @error & @CRLF)
   ConsoleWrite("**** @extended: " & @extended & @CRLF)

   GUISetOnEvent($GUI_EVENT_CLOSE, "OverlayWindow_Exit")
   GUISetState(@SW_SHOW, $hGUI)

   $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
   ConsoleWrite("**** $hGraphics : " & $hGraphics & @CRLF)
   _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)

   $hPen = _GDIPlus_PenCreate(0xFFFF0000, 4)    ; Red

   If ($rectToHighlight <> Null) Then
      _GDIPlus_GraphicsDrawRect($hGraphics, $rectToHighlight[0], $rectToHighlight[1], $rectToHighlight[2], $rectToHighlight[3], $hPen)
   EndIf

   _GDIPlus_PenDispose($hPen)

   $hBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000)  ; RED
   $hFormat = _GDIPlus_StringFormatCreate()
   $hFamily = _GDIPlus_FontFamilyCreate("Arial")
   $hFont = _GDIPlus_FontCreate($hFamily, 14, 2)
   $tLayout = _GDIPlus_RectFCreate($rectForText[0], $rectForText[1], $rectForText[2], $rectForText[3])
   $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $textToWrite, $hFont, $tLayout, $hFormat)
   _GDIPlus_GraphicsDrawStringEx($hGraphics, $textToWrite, $hFont, $aInfo[0], $hFormat, $hBrush)

   _GDIPlus_BrushDispose($hBrush)
   _GDIPlus_StringFormatDispose($hFormat)
   _GDIPlus_FontFamilyDispose($hFamily)
   _GDIPlus_FontDispose($hFont)
   _GDIPlus_GraphicsDispose($hGraphics)

   Return $hGUI
EndFunc

Func OverlayWindow_Exit()
   ConsoleWrite("* * * Exit event called" & @CRLF)
EndFunc

Func Handle_Esc()
   $Done = True
EndFunc

;-----------------------------------------------------------------
;Main()

_GDIPlus_Startup()

Global $Done = False
Local $rect = [10, 10, 400, 400]
Local $rectForText = [15, 15, 380, 380]
$hGUI = OverlayWindow(Null, $rect, $rectForText, "This is a test with long text long text and should automatically wrap long text " & @CRLF & "and " & @CRLF & " handle " & @CRLF & "cariage returns and line feeds")

HotKeySet ( "{Esc}", Handle_Esc)

While Not $Done
   Sleep(100)

WEnd

GUIDelete($hGUI)
_GDIPlus_Shutdown ()
Exit 0

 


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

Hi,

 

Thanks, but I get some errors... I can't solve them...

 

C.

Share this post


Link to post
Share on other sites

"got some errors" doesn't tell us much, what errors?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

error found... the include file was commented

BUT,... it doesn't get the behaviour I am looking for.

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites
1 hour ago, cramaboule said:

BUT,... it doesn't get the behaviour I am looking for.

Why not, what is it doing that it's not supposed to be doing, or what is it not doing that it is supposed to be doing? You could try being a whole lot less vague in your error descriptions, otherwise no one has a clue what you are doing wrong.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Yes... sorry I must be more acurate:

I got the same behaviour as this post: 

 

and I tried to play a bit with the child and parent window but didn't get trough...

How to put the video underneath and the text above?

Share this post


Link to post
Share on other sites

Try again, untested.

#include <FileConstants.au3>
#include <WinAPIFiles.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPISysWin.au3>

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode

; #FUNCTION# ====================================================================================================================
; Name ..........: OverlayWindow
; Description ...:  Throws up a child window with transparent background over current window
;
; Parameters :
;   $hwndParent         parent hwnd
;   $rectToHighlight    rect to draw (or if null, skip)
;   $rectForText    rect for textToWrite
;   $textToWrite    the text to write
; ===============================================================================================================================
Func OverlayWindow($hwndParent, $rectToHighlight, $rectForText, $textToWrite)

   $style = $WS_POPUP
   $exstyle = BitOR($WS_EX_TOPMOST, $WS_EX_TRANSPARENT, $WS_EX_LAYERED)

   $hGUI = GUICreate("transparent overlay", 420, 420, 0, 0, $style, $exstyle)
   GUISetBkColor(0x112233)
  _WinAPI_SetLayeredWindowAttributes($hGUI, 0x112233, 0, $LWA_COLORKEY)

   ConsoleWrite("**** $hGUI: " & $hGUI & @CRLF)
   ConsoleWrite("**** @error: " & @error & @CRLF)
   ConsoleWrite("**** @extended: " & @extended & @CRLF)

   GUISetOnEvent($GUI_EVENT_CLOSE, "OverlayWindow_Exit")
   GUISetState(@SW_SHOW, $hGUI)

   $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
   ConsoleWrite("**** $hGraphics : " & $hGraphics & @CRLF)
   _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)

   $hPen = _GDIPlus_PenCreate(0xFFFF0000, 4)    ; Red

   If ($rectToHighlight <> Null) Then
      _GDIPlus_GraphicsDrawRect($hGraphics, $rectToHighlight[0], $rectToHighlight[1], $rectToHighlight[2], $rectToHighlight[3], $hPen)
   EndIf

   _GDIPlus_PenDispose($hPen)

   $hBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000)  ; RED
   $hFormat = _GDIPlus_StringFormatCreate()
   $hFamily = _GDIPlus_FontFamilyCreate("Arial")
   $hFont = _GDIPlus_FontCreate($hFamily, 14, 2)
   $tLayout = _GDIPlus_RectFCreate($rectForText[0], $rectForText[1], $rectForText[2], $rectForText[3])
   $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $textToWrite, $hFont, $tLayout, $hFormat)
   _GDIPlus_GraphicsDrawStringEx($hGraphics, $textToWrite, $hFont, $aInfo[0], $hFormat, $hBrush)

   _GDIPlus_BrushDispose($hBrush)
   _GDIPlus_StringFormatDispose($hFormat)
   _GDIPlus_FontFamilyDispose($hFamily)
   _GDIPlus_FontDispose($hFont)
   _GDIPlus_GraphicsDispose($hGraphics)

   Return $hGUI
EndFunc

Func OverlayWindow_Exit()
   ConsoleWrite("* * * Exit event called" & @CRLF)
EndFunc

Func Handle_Esc()
   $Done = True
EndFunc

;-----------------------------------------------------------------
;Main()

_GDIPlus_Startup()

Global $Done = False
Local $rect = [10, 10, 400, 400]
Local $rectForText = [15, 15, 380, 380]
$hGUI = OverlayWindow(Null, $rect, $rectForText, "This is a test with long text long text and should automatically wrap long text " & @CRLF & "and " & @CRLF & " handle " & @CRLF & "cariage returns and line feeds")

HotKeySet ( "{Esc}", Handle_Esc)

While Not $Done
   Sleep(100)

WEnd

GUIDelete($hGUI)
_GDIPlus_Shutdown ()
Exit 0

 


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By nacerbaaziz
      hello autoit team
      please i need your help
      i found that the youtube provide a way to get any video informations with this link
      https://youtube.com/get_video_info?video_id=id
      but it incoded i can not read it
      can any one tell me how to decode that please?
    • By CYCho
      This file includes all the source codes and a compiled .exe version of zPlayer, which is a stand-alone, simple, intuitive and easy-to-use, yet fully functional media player.  I made this to suit my purpose and you can tweak it to your taste. The source code is only about 1300 lines and only standard #include files were used.
      zPlayer was my first AutoIt project through which I was hoping to learn coding. A media player capable of playing back audio and video files was my initial goal, but video was beyond my capacity for my lack of coding experience. So zPlayer was born as an audio-only player and remained so up to Version 2.0.1.5.
      Just recently I decided to add video function to zPlayer now that I had gained some experience. I thought it would be possible, but I didn't expect it to be this simple. I made minimal changes to the existing code and added only about 80 lines and, voila, I have an integrated audio and video player, starting from Version 3.0.0.1.
      This player has the following features:
      - Play back all formats of media files which can be palyed back by the Windows Media Player in your computer
      - Depending on the file types specified by the user in zPlayer.ini file this player can be either audio only, video only or both.
      - Video window is independent of other windows and, when it is maximized, increases the immersiveness of the user
      - Graphical player similar to embedded Windows Media Player
      - Forward, backward, pause, repeat, shuffle funtion
      - Increase/decrease/mute sound volume
      - Change folders and create playlist for all media files in that folder and its subfolders, and support for manually-made playlists
      - Save play-back environment when terminating and resume that environment when restarting
      - With one click, you can see internet search results for the file selected in playlist
      - With a double-click, you can play back an item in the playlist
      - Search strings in the playlist
      - Option to see long file names including folder names
      - Resize the playlist and video windows, and restore them to their default positions
      - Very small footprint: very low CPU and memory usage, with only about 1MB when compiled
      - You can even hide all the windows and manipulate the player with hotkeys only
      Note: zPlayer is the name I used when I introduced the early version of this palyer in my blog back in early 2009 and, therefore, has nothing to do with the mobile media player of the same name which started marketing in 2015.
    • By CYCho
      zPlayer is the name I used when I introduced the early version of this palyer in my blog back in early 2009 and, therefore, has nothing to do with the mobile media player of the same name which started marketing in 2015.
      After I retired from active duty in 2002 I spent much time listening to music. First I started with CD's and LP's, then quickly moved on to mp3 files. I converted many of my CD's to mp3 and I collected many more from various sources which were freely available at the time. As the number of my mp3 files grew, I put them in folders according to their genres and my favorite classifications. I mainly used Windows Media Player to listen to them and I slowly began to dislike wmp because it had massive user interface while I just wanted to listen to music in the background while I was doing other work in the foreground, hopping between folders from time to time. It was the time I was beginning to learn AutoIt and I thought I should make my own player with AutoIt. Coming from a sales career with no experience in programming, it was not an easy task. Somehow, after about 2 years of learning and trying, I had my own audio player which worked with only hotkeys without any graphical interface. I gave it to some of my friends who were not as computer-savvy as I. They liked it but definitely wanted something to clcik with mouse. So I came up with very rude gui which took a form similar to what it is now.
      The attached source files include one au3 file, one icon file and 14 jpg files. The jpg files are used for drawing a graphical player and are fileinstalled in @DocumentsCommonDir folder. This player uses WMPlayer.OCX as its engine and supports all audio file formats supported by wmp and additional codecs installed. I would like to thank @Bilgus for kind answers to my questions and would appreciate it if anyone could review the code and give me any suggestion. This player works for me, but I don't know whether the code is presentable as an example. I am posting this here with a hope to learn much from AutoIt community.
      PS: 1. An error (Variable used before declaration) was reported and corrected - 02:00 hours GMT,  March 14, 2019
            2. An error in tray menu was corrected -10:00 hours GMT, March14, 2019
            3. AutoIt3Wrapper_Au3Check_Parameters definition was added at the top of the code and all ensuing errors were corrected. - 00:10 hours GMT, March 16 2019
            4. Some features were added. - 10:30 hours GMT, March 18, 2019
                a. Jumping to new play-back position in a file
                b. Support for a manually made playlist
                c. Ctrl+Alt+h hotkey to trigger a help message box
            5. The minimum resizing width of playlist window was set at 450. - 01:10 hours GMT, March 23, 2019
            6. Problems associated with actions taken while in 'paused' status was addressed. - 07:40 GMT, April 12, 2019
            7. An error was found and corrected in restoring previous play-back environment when the mode was 'Shuffled.' - 11:00 GMT, April 17, 2019


      Please see Downloads section of this forum for source code files.
       
    • By nacerbaaziz
      goodmorning; autoit team
      please their are any youtube search way working?
      because i was using the get source and split it to get the result but know it does not working any way.
      is the youtube disabled that? and is their any other simple way to do that?
      i tested all examples found in this post but also it don't work
      https://www.autoitscript.com/forum/topic/123945-youtube-search/
      and here is the example that i use to and it don't work any more
      local $hSearchOpenHNDL, $hSearchConnect, $sSearchGet local $a_UrlsArray[1][5] local $b_ButtonsDisabled = false, $b_SearchBTNFocus = false, $b_SearchListFocus, $h_SearchFocusHND local $Return = "0" local $s_OpenStringY = "/feed/trending" local $ChannelUrl = "", $channelName = "" if Not ($a_YoutubeSearchArray[0][0] = 0) then GUICtrlSetData($searchInp, $s_youtubeSearchLastSearch) $s_OpenStringY = "/results?search_query=" & StringReplace(GUICtrlRead($searchInp), " ", "+") $a_UrlsArray = $a_YoutubeSearchArray for $i = 1 to $a_UrlsArray[0][0] _GUICtrlListBox_AddString($SearchList, $a_UrlsArray[$i][0] & $a_UrlsArray[$i][2] & $a_UrlsArray[$i][3]) next _GUICtrlListBox_SetCurSel($SearchList, $I_youtubeSearchLastIndex-1) GUICtrlSetState($SearchList, $GUI_focus) else if Ping("youtube.com", 1000) > 1 then $hSearchOpenHNDL = _WinHttpOpen('') if not (@Error) then $hSearchConnect = _WinHttpConnect($hSearchOpenHNDL, "youtube.com") if Not (@Error) then $sSearchGet = _WinHttpSimpleRequest($hSearchConnect, "get", $s_OpenStringY) if not (@Error) then local $a_strings = _StringBetween($sSearchGet, '<a href="/watch', "<ul") local $title = "" local $url = "" local $length = "" local $result = "" GUICtrlSetData($SearchList, "") ReDim $a_UrlsArray[1][5] for $i = 0 to UBound($a_strings)-1 $url = _StringBetween($a_strings[$i], "?", '"') if @error then ContinueLoop $url = "https://www.youtube.com/watch?" & $url[0] $title = _StringBetween($a_strings[$i], 'dir="', '</a>') if @error then ContinueLoop $title = $title[0] $title = StringRegExpReplace($title, '(.*\"\>)', "") if StringRegExp($a_strings[$i], '[0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}', 0) = 1 then $length = StringRegExp($a_strings[$i], '[0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}', 2) elseIf StringRegExp($a_strings[$i], '[0-9]{1,2}\:[0-9]{1,2}', 0) = 1 then $length = StringRegExp($a_strings[$i], '[0-9]{1,2}\:[0-9]{1,2}', 2) else $length = "" endIf if IsArray($length) then $length = ": (" & $length[0] & ")" else $length = "" endIf $ChannelUrl = stringRegexpReplace($a_strings[$i], '(^.*?<a.*?\"(\/user|\/channel))+', "$2") $channelName = stringRegexpReplace($ChannelUrl, '(.*?\".*?>)(.*</a>)+', "$2") $ChannelUrl = stringRegexpReplace($ChannelUrl, '(\".*)+', "") $channelName = stringRegexpReplace($channelName, '(</a>.*)+', "") $result &= $title & @crlf & $url & @crlf ReDim $a_UrlsArray[UBound($a_UrlsArray)+1][5] $a_UrlsArray[UBound($a_UrlsArray)-1][0] = $title $a_UrlsArray[UBound($a_UrlsArray)-1][1] = $url $a_UrlsArray[UBound($a_UrlsArray)-1][2] = $length if not ($channelName = "") then $a_UrlsArray[UBound($a_UrlsArray)-1][3] = ", (" & $channelName & ")" if not ($channelUrl = "") then $a_UrlsArray[UBound($a_UrlsArray)-1][4] = "https://www.youtube.com" & $channelUrl $a_UrlsArray[0][0] = UBound($a_UrlsArray)-1 _GUICtrlListBox_AddString($SearchList, $a_UrlsArray[UBound($a_UrlsArray)-1][0] & $length & $a_UrlsArray[UBound($a_UrlsArray)-1][3]) next endIf endIf endIf endIf endIf  
      i hope any one can help me
      thanks in advance
×
×
  • Create New...