vnlagrla Cheater
Reputation: 0
Joined: 10 Apr 2011 Posts: 33
|
Posted: Tue Feb 07, 2012 3:39 pm Post subject: |
|
|
I am Targeting a specific window. After searching google over free Period and lunch. I got it to work by converting a VB source to C# and here is how it looks
Win32
| Code: |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace sendkey
{
public static class Win32
{
public const int WM_SETCURSOR = 0x020;
public const int WM_COMMAND = 0x111;
public const int WM_KEYDOWN = 0x100;
public const int WM_KEYUP = 0x101;
public const int WM_CHAR = 0x102;
public const int WM_MOUSEMOVE = 0x200;
public const int WM_LBUTTONDOWN = 0x201;
public const int WM_LBUTTONUP = 0x202;
public const int WM_LBUTTONDBLCLK = 0x203;
public const int GWL_EXSTYLE = -20;
public const int WS_EX_TOOLWINDOW = 0x00000080;
public const int WS_EX_APPWINDOW = 0x00040000;
public const int WM_SETTEXT = 0x0C;
[DllImport("User32.dll")]
public static extern IntPtr FindWindow(string strClassName, string strWindowName);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);
[DllImport("User32.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, IntPtr Msg, IntPtr wParam, string lParam);
}
} |
Main
| Code: |
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;
namespace sendkey
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void Sendkey()
{
IntPtr notepadHwnd = Win32.FindWindow(null, "Untitled - Notepad");
IntPtr editHwnd = Win32.FindWindowEx(notepadHwnd, (IntPtr)0, "Edit", null);
Win32.SendMessage(editHwnd, (IntPtr)Win32.WM_SETTEXT,(IntPtr) 0, "programatically added text!");
}
private void button1_Click(object sender, EventArgs e)
{
Sendkey();
}
}
} |
|
|