a亚洲精品_精品国产91乱码一区二区三区_亚洲精品在线免费观看视频_欧美日韩亚洲国产综合_久久久久久久久久久成人_在线区

首頁 > 編程 > C# > 正文

c# 在WebBrowser中用SendMessage模擬鼠標點擊

2024-09-07 17:05:27
字體:
來源:轉載
供稿:網(wǎng)友
代碼如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace BrowserMouseClick
{
public partial class Form1 : Form
{
     [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
     static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

     [DllImport("user32.dll", SetLastError = true)]
     static extern IntPtr GetWindow(IntPtr hWnd, uint uCmd);

     [DllImport("user32.dll", CharSet = CharSet.Auto)]
     static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);

     public Form1()
     {
         InitializeComponent();
     }

     private void Form1_Load(object sender, EventArgs e)
     {
         webBrowser1.Navigate("http://www.devpub.com");
     }

     private void btnMouseClick_Click(object sender, EventArgs e)
     {
         int x = 100; // X coordinate of the click
         int y = 80; // Y coordinate of the click
         IntPtr handle = webBrowser1.Handle;
         StringBuilder className = new StringBuilder(100);
         while (className.ToString() != "Internet Explorer_Server") // The class control for the browser
         {
             handle = GetWindow(handle, 5); // Get a handle to the child window
             GetClassName(handle, className, className.Capacity);
         }

         IntPtr lParam = (IntPtr)((y << 16) | x); // The coordinates
         IntPtr wParam = IntPtr.Zero; // Additional parameters for the click (e.g. Ctrl)
         const uint downCode = 0x201; // Left click down code
         const uint upCode = 0x202; // Left click up code
         SendMessage(handle, downCode, wParam, lParam); // Mouse button down
         SendMessage(handle, upCode, wParam, lParam); // Mouse button up
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 国产一二在线 | 九九九色 | 国产色网| 在线观看黄色av | 日韩欧美色| 精品超碰 | 欧美成人免费在线视频 | 日韩一级片免费在线观看 | 午夜欧美一区二区三区在线播放 | 国产亚洲精品久久久久动 | 成人免费在线 | 在线成人 | 欧美精品一区二区三区在线播放 | 99久久99热这里只有精品 | 亚洲成人一区 | 黄色综合网 | 日韩一区在线观看视频 | 亚洲精品乱码久久久久v最新版 | 日韩中文一区二区三区 | 一区二区三区四区国产 | 99成人| 日韩一区二区在线观看 | 久草视 | 国产高清不卡在线 | 国产精品高潮呻吟久久av黑人 | 国产偷v国产偷v亚洲 | 亚洲一区二区三区四区 | 国产99在线 | 欧美 | 日韩2020狼一二三 | 亚洲国产欧美一区二区三区久久 | 欧美精品在线观看 | 亚洲欧美视频一区 | 免费看h| 密室大逃脱第六季大神版在线观看 | 亚洲精品久久久久久久久 | 岛国免费av | 国产精品一品二区三区的使用体验 | 九九99久久| 国产综合精品一区二区三区 | 狠狠爱www人成狠狠爱综合网 | 天天摸夜夜摸爽爽狠狠婷婷97 |