Original Post
Hi, I'm trying to make a program to make a program that makes you able to surf to a page. Then you should be able select a few things (selecting = just one mouseclick) (so you'd be able to give in a set of coordinates and it would click on those places in the browser) And for the coordinates, you should be able to hover over the starting position, then press a so it knows that the first click will be there, from then on I could just adjust the other coordinates according tot that position : ) (but there is no mousemove event for the webbrowser.. ? ) BUT the problem is.. None of the things I've tried seem to work :S - to start of with, I've really searched a lot to get it to click inside the webbrowser but it doesn't seem to work.. here's the code I have so far..
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;
namespace WindowsFormsApplication1
{
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);
int X = 5;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
site.Navigate(input.Text);
}
private void button2_Click(object sender, EventArgs e)
{
IntPtr handle = site.Handle;
StringBuilder className = new StringBuilder(100);
while (className.ToString() != "Internet Explorer_Server") // your mileage may vary with this classname
{
handle = GetWindow(handle, 5); // 5 == child
GetClassName(handle, className, className.Capacity);
}
IntPtr lParam = (IntPtr)((y << 16) | x); // X and Y coordinates of the click
const IntPtr wParam = IntPtr.Zero; // change this if you want to simulate Ctrl-Click and such
const uint downCode = 0x201; // these codes are for single left clicks
const uint upCode = 0x202;
SendMessage(handle, downCode, wParam, lParam); // mousedown
SendMessage(handle, upCode, wParam, lParam); // mouseup
}
private void button2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.A)
{
MessageBox.Show("blub");
}
}
}
}
Error 1 The name 'y' does not exist in the current context C:\Users\Pieter\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.cs 49 39 WindowsFormsApplication1 Error 2 The name 'x' does not exist in the current context C:\Users\Pieter\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.cs 49 50 WindowsFormsApplication1 Error 3 The type 'System.IntPtr' cannot be declared const C:\Users\Pieter\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.cs 50 19 WindowsFormsApplication1