日期:2014-05-17 浏览次数:21054 次
public void sendMessage()
{
IntPtr ip = IntPtr.Zero;
if (Regex.IsMatch(text_Intptr.Text.Trim(), @"^[a-fA-F0-9]+$"))
ip = (IntPtr)Convert.ToInt32(text_Intptr.Text.Trim(), 16);
else
{
ip = FindWindow("TXGuiFoundation", TextBox_Title.Text.Trim());
if (ip.ToInt32() == 0)
ip = GetIntPtr();
if (ip == IntPtr.Zero)
{
MessageBox.Show("请输入正确的标题");
return;
}
}
SetForegroundWindow(ip);
SetActiveWindow(ip);
var str = "";
var rtf = "";
richTextBox1.Invoke(new MethodInvoker(() => { str = richTextBox1.Text.Trim(); rtf = richTextBox1.Rtf.Trim(); }));
while (true)
{
if (ip.ToInt32() == GetForegroundWindow().ToInt32())
{
foreach (byte c in Encoding.Default.GetBytes(str))
{
SendMessage(ip.ToInt32(), 0x101, (int)c, 1);
SendMessage(ip.ToInt32(), 0x102, (int)c, 1);
&n