Caspar Screen Consumer

Hi all,

I have two questions:),

How to make casparCG screen consumer always on top, and is there any possibility to add screen consumer inside C# application, like to have preview of graphic all the time?

There are tools that can be used for this

Yes, I have that code, a modified version of something Vimlesh once shared. But it’s in VB.NET. See here:

   'Declaring some constants to use with the SendMessage API
   Private Const WM_SYSCOMMAND As Integer = 274
   Private Const SC_MAXIMIZE As Integer = 61488
   Private Const SC_MINIIMIZE As Integer = 61472

   'This is the API that does all the hard work
   <Runtime.InteropServices.DllImport("user32.dll")> _
   Public Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
   End Function

   <Runtime.InteropServices.DllImport("user32.dll")> _
   Public Shared Function FindWindow(ByVal lpszClass As String, ByVal lpszWindow As String) As Integer
   End Function

   <Runtime.InteropServices.DllImport("user32.dll")> _
   Public Shared Function FindWindowEx(ByVal hwndParent As IntPtr, ByVal hWndChildAfter As IntPtr, ByVal lpszClass As String, ByVal lpszWindow As String) As Integer
   End Function

   'This is the API used to maximize the window
   <Runtime.InteropServices.DllImport("user32.dll")> _
   Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
   End Function

   'This is the process that is currently set as a child to the form
   Private _parentedProcess As Process
   Private WithEvents timGrab As Timer = New Timer()

   Private Sub SetProcessParent(ByVal processName As String)

      'Retrieve an array of running processes with the given name
      Dim processes() As Process = Process.GetProcessesByName(processName)
      If processes.Length = 0 Then
         MessageBox.Show("No processes by that name found")
      Else
         'If there already is a process set as a child to our form, we set its parent to Nothing, to make it go back to its normal state.
         If Not _parentedProcess Is Nothing Then
            SetParent(_parentedProcess.MainWindowHandle, Nothing)
         End If
         'This forms new child will be the process on index 0 of the array
         _parentedProcess = processes(0)
         SetParent(_parentedProcess.MainWindowHandle, Me.panPreview.Handle)
         'SetParent(_parentedprocess.MainWindowHandle, Me.panPreview.Handle) Try adding a panel to your form and use this line instead of the above line.

         'Now lets maximize the window of the process
         SendMessage(_parentedProcess.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)

      End If

   End Sub

   Private Sub timGrab_Tick(sender As Object, e As System.EventArgs) Handles timGrab.Tick
      timGrab.Enabled = False
      SetProcessParent("casparcg")
   End Sub

And, if you put that into a form, add this code to it:

   Private Sub frmPreview_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
      'This is important! If you have a child process on your form, it will terminate along with your form if you do not set its parent to Nothing

      If Not _parentedProcess Is Nothing Then
         SetParent(_parentedProcess.MainWindowHandle, Nothing)
      End If
   End Sub

   Private Sub frmPreview_Load(sender As Object, e As System.EventArgs) Handles Me.Load
      timGrab.Interval = 1000
      timGrab.Enabled = True
   End Sub

I hope this helps

1 Like

I wish I would asked this two days ago.
Ended up using NDI for client preview (alpha channel is an advantage too)

stay on top is / will be an option in 2.2

Exactly what i wanted to suggest for a next version :slight_smile: :slight_smile: How stable is 2.2 version now?

It’s getting there but there are still quite some issue’s

i would not recommend using it blindfolded on your next production.

but in a self controlled enviroment with known content and knowing the cavities
and good testing it is becoming usable

i did a few productions with it already
most problems are now in videoplayback and information feedback OSC/INFO

CG work is working pretty well

I currently prepares two quiz applications, and i work on stable 2.0.7, but i think for that there is no need to switch on 2.1 or 2.2 What are benefits regarding CG only, not video playout in new versions of server?

HTML has been upgraded a enormous step vs 2.07

Hi guys !
I am new to CasparCG world, I am trying to get at least a situation for starting using it as a pro player, until now most of things I tried works but the most important one no !
I am trying to configure the server in a way to open in the secondary output screen in full screen mode and with no window bar.
but if i don’t keep the window bar then I am not able to position the screen window correctly, the problem is that you keep the window bar…
The last set up i tried was this:

<video-mode>1080p5000</video-mode>
        <consumers>
          <screen>
            <device>2</device>            
            <always-on-top>true</always-on-top> 
            <borderless>false</borderless>                 
          </screen>

<borderless>false</borderless> and <windowed>false</windowed> for me do the same job, but maybe i am wrong
I tried also to use this parameters:

<x>0</x>
<y>0</y>
<width>1920</width>
<height>1080</height>

but no results …
It’s always bigger than my output and need to be resized…
I have checked my output resolution and it’s match the configuration setting
Simply I have no idea
Thanks !!
c11|690x194

The img is referring to the situation where I keep the window bar and then I am able to correctly positioning the screen window
in this img you see what happen if i don’t let the bar window available

Sorry my first post missed the strings that i was referring to:
the current set up

<screen>
            <device>2</device>            
            <always-on-top>true</always-on-top> 
            <borderless>false</borderless>                 
          </screen>

Please check if you have set all display settings to 100% in control panel. That could be the reason for the screen consumer to appear too big.

And use the button </> to format your config sections here in the forum (I did that for you) other ways a
<width>1920</width> ist only displayed as 1920 and that is confusing.

1 Like

I use cmdow.exe in my client software, a small software of 87Kb which allows to resize windows, to put windows on top or not, etc …

ex:

cmdow.exe "* consumer [2 *" /TOP
cmdow.exe "* consumer [2 *" /NOT