-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
USER32.SendInput with MOUSEEVENTF_WHEEL does not work in .NET 9 #111249
Comments
I noted in the bug report in FlaUI that it doesn't appear to be an issue with UIPI blocking. See my comment there for additional details about that. |
I tossed the binaries produced by both |
Problem is not with marshalling or WinApi. It is related to overflow calculation (in your case, its happening when calling On .NET 8 following code prints Console.WriteLine(Test(-1));
uint Test(double d) => (uint)(120 * d); This breaking change is known and documented here: https://learn.microsoft.com/en-us/dotnet/core/compatibility/jit/9.0/fp-to-integer |
Tagging subscribers to this area: @dotnet/area-system-numerics |
Worth explicitly noting (even though it's covered in the breaking change doc) that the previous floating-point to integer conversion behavior depended on what the underlying hardware supported. What this means is that while you discovered the break on .NET 9 where the behavior was explicitly normalized across all hardware, it was actually already broken in .NET 8 (and older targets). In particular you would definitely see the same failure on Arm64 and you might see the same failure on an x64 machine with AVX512 support. As such, this may be a behavior you want to explicitly handle on all targets, not just .NET 9 |
Description
SendInput
can be P/Invoked with theMOUSEEVENTF_WHEEL
flag in order to simulate using the scroll wheel on a mouse.This works in .NET versions < 9. However, this does not work in .NET 9.
Reproduction Steps
The following code is available here.
Here is a video demonstrating the following.
<TargetFramework>net9.0-windows</TargetFramework>
in the.csproj
tonet8.0-windows
Program.cs
.csproj
The
cswin32
project is used here to reduce the amount of code in this reproduction. It should be noted that I first observed this issue in the FlaUI project which does not usecswin32
but instead has hand-crafted all the relevant structs and function signatures. In other words, this isn't caused by thecswin32
project.Expected behavior
Long documents ought to scroll when the mouse is over them and when "Scroll" is printed to the console, no matter the
TargetFramework
.Actual behavior
Long documents only scroll when the mouse is over them and when "Scroll" is printed to the console, and when
TargetFramework
isnet8.0-windows
or older.Regression?
Works in
net8.0-windows
.Known Workarounds
Avoid .NET 9.
Configuration
I also observe this behavior in Hyper-V VMs running relatively fresh installations of Windows 11 Pro (23H2) with the .NET 9.0.101 SDK installed.
Other information
No response
The text was updated successfully, but these errors were encountered: