1

My script:"
import ctypes
import ctypes.wintypes as wintypes
import win32gui

WM_COPYDATA = 0x004A

class COPYDATASTRUCT(ctypes.Structure):
    _fields_ = [
        ("dwData", wintypes.LPARAM),
        ("cbData", wintypes.DWORD),
        ("lpData", wintypes.LPCVOID),
    ]

def send_command_to_kinovea(command_string):
    hwnd = win32gui.FindWindow(None, "Kinovea [Record]")  # Adjust title as needed
    if not hwnd:
        print("Kinovea window not found.")
        return False

    encoded = command_string.encode("utf-8")
    buffer = ctypes.create_string_buffer(encoded + b"\0")
    cds = COPYDATASTRUCT()
    cds.dwData = 0
    cds.cbData = len(buffer)
    cds.lpData = ctypes.cast(buffer, wintypes.LPCVOID)

    result = ctypes.windll.user32.SendMessageW(
        hwnd,
        WM_COPYDATA,
        0,
        ctypes.byref(cds)
    )

    print(f"Sent command '{command_string}' to Kinovea. Result: {result}")
    return True

send_command_to_kinovea("Kinovea:DualCapture.ToggleRecording")
"
Returns
C:\Users\wrink>python togglerecordkinovea.py
Sent command 'Kinovea:DualCapture.ToggleRecording' to Kinovea. Result: 0

However no recording is triggered. I can trigger the recording with the keyboard shortcut under preferences however. Im hoping to automate the trigger base on a tracable software event.

2

Hi,
Unfortunately there is a bug with dual recording commands in the released version. The ones for single capture screen should work, can you confirm that? This script seems massively useful.

I fixed the issue in the source code a while back but haven't made progress on the other things I wanted to include in the next release.

3

(offtopic) but hrynkiw30 thank you! I have spent the last few days trying to make vb.net or c#.net send commands and kept getting errors in the log.
27256 - DEBUG - [Main] - KinoveaMainWindow - Received WM_COPYDATA.
27256 - ERROR - [Main] - KinoveaMainWindow - Unrecognized command.

With reviewing your code I now have a working copy of both c# and vb.net. THANK YOU!