Jump to content

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

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
15 minutes ago, cramaboule said:

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

My suggestion: Keep looking. ;)


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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

  • Similar Content

    • By dascondor
      So basically need to pull text from a .txt file or .sql and use that text to replace something within a different file.
       
      First File:
      jumps
       
      Or:
      Text1 = jumps
      Text2 = fence
      Second File:
      My Dog XXXXX over the YYYYY.
       
       
      After Script:
      My Dog jumps over the fence
       
      I have found a good start, I'm basic programmer at best, I have some experience but this gets out of my wheel house.
       
      Any help is appreciated.
       
       
    • By UEZ
      AutoIt Windows Screenshooter
      Key Features:
      takes easily a screenshot from any visible window capture any region of the desktop incl. freehand capturing capture GUI controls and GUI menus separately capture a marked area every x seconds for a duration of y seconds create a GIF animation from saved frames (Vista or higher os required) capture to AVI file (without audio!) takes a screenshot from web sites (available only on Win7+ os and when Aero is enabled) put images to clipboard to paste to other applications easily color picker save image in different formats and also to PDF! add timestamp to saved images simple image editing options: greyscale, b&w, invert, rotate +-90° send image to printer and default email client preview of captured screens incl. zoom option multi monitor support display pixel color under mouse ruler basic image editor (paint, highlight, ellipse, rectangle, text and some graphic FX) watermark captured image no 3rd party tools or DLLs used - pure AutoIt! fully portable - no installation is needed multi language feature (Eng, Ger, Tur, Fra and Rus only) To do:
      capture content of scrollable window/control capture cascaded menus Due to DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "handle", $hMemDC, "int", 0) limitation some windows cannot be captured properly (GDI+, ProgDVB, etc.) but can take screenshots of hidden windows. One workaround is to use full screen capturing (F11/F12) or "Grab Screen" function! Or try double click with rmb on listview items (beta).
      Download source code (7858 downloads previously): AutoIt Windows Screenshooter v1.82 Build 2019-02-03.7z (version 3.3.12.0+ needed!)
      You are not allowed to sell this code or just parts of it in a commercial project or modify it and distribute it with a different name!
      Download compiled Exe only: 4shared / Media Fire  / Softpedia (1.54mb)
      Distributing copies of the program in compiled format (exe) must be free of any fee!
      -----> click here to Donate!  
       
      (Current donators: 1. Cuong N.) 
      It is designed for Win7+ operating systems with AERO enabled! E.g. on WinXP machines some functions are not working properly and might crash the application!
      AV scanners may have a negative impact the execution of compiled exe and might report any malware. I guarantee that there is no malicious code in the source code / exe!!! 
      Main GUI:

       
       
      About Intro:

       
       
      Basic Image Editor:

       
       
      Watermark:

       
       
      Click link for an enhanced version of Watermark Image.
      Credits:
      main code by UEZ additional code (alphabetical order) by Authenticity, AutoItObject Team, Eemuli, Eukalyptus, funkey, _Kurt, martin, monoceres, ProgAndy, taietel, trancexx, Ward, wolf9228 and Yashied! mesale0077 for turkish translation wakillon for french translation AZJIO for russian translation Keys:
      Main GUI:
      User your mouse to scroll preview window or
      Numpad 8: Scroll preview window up
      Numpad 2: Scroll preview window down
      Numpad 4: Scroll preview window left
      Numpad 6: Scroll preview window right
      Numpad +: zoom in preview window or mouse wheel down
      Numpad -: zoom out preview window or mouse wheel up
      F1: capture again on last position
      F5: refresh Windows Name list
      PRINTSCREEN: take screenshot from whole screen
      ALT+PRINTSCR: take a screenshot from active window
      F10: Undo made changes with Image Editing function
      F11: take screenshot from whole screen incl mouse cursor
      F12: take screenshot from whole screen
      Ctrl+Alt+F9 start "Grab Screen" mode
      Ctrl+Alt+F12: take a screenshot from active window using alternative screenshot functionality (beta)!
      Ctrl+r: call ruler
      Ctrl+s: save current displayed image
      Ctrl+x: exit program
      ctrl+w: call web grab input field (available only when Aero is enabled)
      Ctrl+i: call image editor
      Ctrl+m: call watermark editor
      Ctrl+z: undo
      Only available on Vista+ os: double click with rmb on list items to use alternative screenshot functionality (beta)!
      When 'Grab Screen' is clicked you can hold down the ctrl key to switch to 'grab controls' mode. Control under mouse will be framed red.
      ctrl + shift will take the screenshot of appropriate control. To capture GUI menus you can press rmb which simulates the lmb. When a menu is opened press shift additionally to capture it.
      Press and hold only the shift key to capture any region on the desktop using freehand capturing - release it so capture marked regions!
      Or just mark resize able area which you want to grab. Press CTRL key to grab marked area or right mouse button to capture the marked area every x seconds for a duration of y seconds.
      When saving the image just enter the extension you wish to use (*.jpg;*.png;*.bmp;*.gif;*.tif;*.pdf). Big thanks to taietel for his PDF UDF!
      Image Editor:
      s: save
      c: copy
      n: send
      h: highlighter
      p: pen
      r: rectangle
      e: ellipse
      a: arrow
      o: color
      t: text
      g: text config
      Ctrl+z: undo
      Watermark editor:
      Ctrl+z: undo
       
      To start the app minimized just call it "Windows Screenshooter.exe /min"
      Maybe it is useful for someone...
      Any kind of comment is welcome.
      Br,
      UEZ
      Change log:
       
    • By misioooo
      Hi!
       
      I am writing some GUI and i need to use images as buttons, but with text on them (text is from INI file).
      Part with button looks like this:
      $ankieta1 = GUICtrlCreateButton($txtAnk1, 100,350,765,164) GUICtrlSetFont(-1, 22, 800, -1, "Arial") ;GUICtrlSetColor(-1,0xffffff) $hImageBtn_1 = _GUIImageList_Create(765, 164) _GUIImageList_AddBitmap($hImageBtn_1, "c:\path\to\ankieta_clean.bmp") _GUICtrlButton_SetImageList($ankieta1, $hImageBtn_1, 4) GUICtrlSetOnEvent(-1, "On_Ankieta1") The problem - if i uncomment GUICtrlSetColor, color of text changes, but button is just plain gray (no image). How i can change text color not touching image on a button here?
    • By vin1
      i have a script that selects  a text file and deletes a line (text input required) in the text file selected
      i have to make it remove all lines found on a file i name, toRemoveLines.txt
      it has to remove lines from all text files found in a folder
      this is the script that has to be modified
      where it says "select file" it has to be "select folder"
      where it says "line text input" it has to be all lines from a text file
      #Include <File.au3> Global $success = False $file_name = FileOpenDialog("Select file", @ScriptDir, "All files (*.*)", 1+4) $line_text_input = InputBox("Line's text", "Line must contain following text:", "line contains this text") $file_count_lines = _FileCountLines($file_name) for $i = 0 to $file_count_lines $Lines_text_output = FileReadLine($file_name, $i) if StringInStr($Lines_text_output, $line_text_input) then _FileWriteToLine($file_name, $i, "", 1) $success = True ExitLoop EndIf Next if $success = True Then MsgBox(0, "Success", "Line has been deleted") Else MsgBox(0, "Failure", "Line wasn't found") EndIf  
    • By Sven-Seyfert
      Hi Community,

      I use a UDF by @smashly to play a video in a GUI. That works fine for my main monitor.
      But when I change the X and Y positions of the GUI (also for the video) to my second or third monitor, the video plays, I can hear the sound of it, but I don't see the video.

      I debugged the UDF and checked the Microsoft description for MCI Command Strings which are used in the UDF (docs.microsoft...) - everything is fine, so I got no clue why the video isn't displayed.

      PlayVideoTest.au3:
       
      VideoInGui_by_Smashky.au3 (UDF):
       
      The example video:
       
      It would be great when anyone can help .
      Is there maybe a other way to play (display videos in GUI)?

      Thanks for any suggestion - I'm grateful!
      Sven
×
×
  • Create New...