c# 坐标点击webBrowser1

ACE-Step

ACE-Step

音乐合成
ACE-Step

ACE-Step是由中国团队阶跃星辰(StepFun)与ACE Studio联手打造的开源音乐生成模型。 它拥有3.5B参数量,支持快速高质量生成、强可控性和易于拓展的特点。 最厉害的是,它可以生成多种语言的歌曲,包括但不限于中文、英文、日文等19种语言

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using mshtml;
 
namespace baidu
{
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);
 
HtmlDocument htmlDocument;
 
public Form1()
{
InitializeComponent();
}
 
[DllImport("user32")]
public static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
 
 
/*
             获取位置
      */
    
public void location()
{
htmlDocument.GetElementById("kw").SetAttribute("value", "nihao");
 
Point p = new Point();
 
HTMLDocument doc = webBrowser1.Document.DomDocument as HTMLDocument;
 
IHTMLElementCollection els = doc.getElementsByTagName("INPUT");
 
foreach (IHTMLElement em in els)
{
 
// URL www.baidu.com
if (em.getAttribute("value") == "百度一下")
{
IHTMLElement pem = em;
//元素中间
p.X = em.offsetWidth / 2;
//MessageBox.Show(p.X.ToString());
p.Y = em.offsetHeight / 2;
//MessageBox.Show(p.Y.ToString());
do
{
pem = pem.offsetParent;
p.X += pem.offsetLeft;
p.Y += pem.offsetTop;
} while (pem.tagName.ToLower() != "body");
//MessageBox.Show(p.X.ToString());
//MessageBox.Show(p.Y.ToString());
em.scrollIntoView();//显示元素
break;
}
}
}
 
 
 
       /*
             点击
      */
public void button2_Click()
{
htmlDocument.GetElementById("kw").SetAttribute("value", "success");
 
// 这里是location方法 获取的位置
int x = 789; // X coordinate of the click
int y = 238; // Y coordinate of the click
IntPtr handle = webBrowser1.Handle;
StringBuilder className = new StringBuilder(789);
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
 
}
 
private void webBrowser1_DocumentCompleted_1(object sender, WebBrowserDocumentCompletedEventArgs e)
{
this.htmlDocument = webBrowser1.Document;
 
//location();
 
button2_Click();
 
}
}
}
 
//这算是我从别的地方获取并总结出来的,希望能帮助大家。

您可能感兴趣的与本文相关的镜像

ACE-Step

ACE-Step

音乐合成
ACE-Step

ACE-Step是由中国团队阶跃星辰(StepFun)与ACE Studio联手打造的开源音乐生成模型。 它拥有3.5B参数量,支持快速高质量生成、强可控性和易于拓展的特点。 最厉害的是,它可以生成多种语言的歌曲,包括但不限于中文、英文、日文等19种语言

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序007

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值