Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions WinSyncScroll/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,20 @@ private async Task RunMouseEventProcessingLoopAsync(
if (!_options.Value.IsLegacyModeEnabled)
{
LogSendInput(inputs);
PInvoke.SendInput(inputs.AsSpan(), SizeOfInput);
var sentCount = PInvoke.SendInput(inputs.AsSpan(), SizeOfInput);

if (sentCount != inputs.Length)
{
var lastError = Marshal.GetLastWin32Error();
_logger.LogError("SendInput failed: expected to send {ExpectedCount} events, but only {SentCount} were sent. Last Win32 error: {LastError}",
inputs.Length,
sentCount,
lastError);
}
else
{
_logger.LogTrace("Successfully sent {SentCount} input events", sentCount);
}
}
else
{
Expand All @@ -369,7 +382,20 @@ private async Task RunMouseEventProcessingLoopAsync(
lParam,
targetX,
targetY);
PInvoke.PostMessage(windowHandle, (uint)buffer.MouseMessageId, (nuint)buffer.MouseMessageData.mouseData, lParam);

var result = PInvoke.PostMessage(windowHandle, (uint)buffer.MouseMessageId, (nuint)buffer.MouseMessageData.mouseData, lParam);

if (!result)
{
var lastError = Marshal.GetLastWin32Error();
_logger.LogError("PostMessage failed for window {WindowHandle}: Last Win32 error: {LastError}",
windowHandle,
lastError);
}
else
{
_logger.LogTrace("Successfully posted message to window {WindowHandle}", windowHandle);
}
}
}
}
Expand Down