I added the UIAutomationClient dll but it was still couldn't find the System.Windows.Automation in my .net8 console application.
Google Gemini suggested me to add <TargetFramework>net8.0-windows</TargetFramework> into the <PropertyGroup> in the csproj file of my project. Then the visual studio could find the library succesfully.
Edit: Also I needed to add <UseWPF>true</UseWPF> into <PropertyGroup> thanks to the @Zhijian Jim Luo's suggestion.