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.