问题
I am creating a CONSOLE application, I need to scroll a certain part of the window from positions (x = 350, y = 240) to (x = 350, y = 120) (vertical scroll), I tried different ways but I couldn't. I was also unable to use the WM_MOUSEWHEEL option. Follow the code I use for clicks that work perfectly, I just need to adapt it to click and drag or determine a Y point on the window and use the mouse scroll. Could you please help me? Sorry for bad English, I used a translator.
public class Win32
{
public const int WM_KEYDOWN = 0x100;
public const int WM_KEYUP = 0x101;
public const int WM_COMMAND = 0x111;
public const int WM_LBUTTONDOWN = 0x201;
public const int WM_LBUTTONUP = 0x202;
public const int WM_LBUTTONDBLCLK = 0x203;
public const int WM_RBUTTONDOWN = 0x204;
public const int WM_RBUTTONUP = 0x205;
public const int WM_RBUTTONDBLCLK = 0x206;
[DllImport("User32.dll")]
public static extern Int32 PostMessage(int hWnd, int Msg, int wParam, IntPtr lParam);
}
static void Main(string[] args)
{
IntPtr WinHandle = User32.FindWindow(null, "My Window");
Win32.PostMessage((int)WinHandle, Win32.WM_LBUTTONDOWN, 0x00000001, CreateLParam(350, 240));
Thread.Sleep(100);
Win32.PostMessage((int)WinHandle, Win32.WM_LBUTTONUP, 0x00000000, CreateLParam(350, 120));
Console.Write("Done");
Console.ReadKey();
}
来源:https://stackoverflow.com/questions/62488594/c-sharp-click-and-drag-or-mouse-wheel-with-postmessage-sendmessage