H
Hello everyone
Hello everyone, Ive been trying to get this code to work for very long
now, but I havent been able to catch the problem. Im trying to use the
SendMessage method but when I execute the program nothing happens. Thats
the best response Ive gotten from it so far, other times it mdoesnt
compile. Its a short code, Im trying simply to get SendMessage to click
a button in another specified app when I click my button. Im using c#
express with framework 2.0, the example Ive found for this were all for
older framwork versions and didnt work. Can anyone show me where Im
wrong?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public class Win32
{
[DllImport("user32", EntryPoint = "GetNextWindow")]
public static extern int
GetWindow(IntPtr hwnd, int wFlag);
public const int BM_CLICK = 0x00F5;
[DllImport("user32.dll")]
public static extern int FindWindow(string lpClass, string lpWindow);
[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, uint Msg, int wParam, int
lParam);
}
private void button1_Click(object sender, EventArgs e)
{
int hWnd;
hWnd = Win32API.FindWindow(Class1.Text, caption.Text);
Win32API.SetForegroundWindow(hWnd);
Win32.SendMessage(hWnd, Win32.BM_CLICK, 0, 0);
}
}
}
now, but I havent been able to catch the problem. Im trying to use the
SendMessage method but when I execute the program nothing happens. Thats
the best response Ive gotten from it so far, other times it mdoesnt
compile. Its a short code, Im trying simply to get SendMessage to click
a button in another specified app when I click my button. Im using c#
express with framework 2.0, the example Ive found for this were all for
older framwork versions and didnt work. Can anyone show me where Im
wrong?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public class Win32
{
[DllImport("user32", EntryPoint = "GetNextWindow")]
public static extern int
GetWindow(IntPtr hwnd, int wFlag);
public const int BM_CLICK = 0x00F5;
[DllImport("user32.dll")]
public static extern int FindWindow(string lpClass, string lpWindow);
[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, uint Msg, int wParam, int
lParam);
}
private void button1_Click(object sender, EventArgs e)
{
int hWnd;
hWnd = Win32API.FindWindow(Class1.Text, caption.Text);
Win32API.SetForegroundWindow(hWnd);
Win32.SendMessage(hWnd, Win32.BM_CLICK, 0, 0);
}
}
}