06-02-13, 12:48 AM
كود :
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 ConsoleApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, [Out] StringBuilder lParam);
[DllImport("user32.dll", SetLastError = true)]
private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll", SetLastError = true)]
private static extern IntPtr GetWindow(IntPtr hWnd, GetWindow_Cmd uCmd);
public string fixString(string str)
{
return str.Split(new char[] { ':' })[1].Substring(1);
}
public void getWindowText(IntPtr hwnd)
{
IntPtr hWnd = FindWindowEx(hwnd, IntPtr.Zero, "#32770", null);
for (int i = 0; i < 12; i++)
{
hWnd = GetWindow(hWnd, GetWindow_Cmd.GW_HWNDNEXT);
}
IntPtr ptr3 = FindWindowEx(hWnd, IntPtr.Zero, "Static", null);
for (int j = 0; j < 80; j++)
{
int num3 = (int)SendMessage(ptr3, 14, IntPtr.Zero, null);
if (num3 > 0)
{
StringBuilder builder;
switch (j)
{
case 20:
builder = new StringBuilder(num3 + 1);
SendMessage(ptr3, 13, (IntPtr)builder.Capacity, builder);
Values.Name = this.fixString(builder.ToString());
goto Label_02EE;
case 0x15:
builder = new StringBuilder(num3 + 1);
SendMessage(ptr3, 13, (IntPtr)builder.Capacity, builder);
Values.Level = this.fixString(builder.ToString());
goto Label_02EE;
case 0x16:
builder = new StringBuilder(num3 + 1);
SendMessage(ptr3, 13, (IntPtr)builder.Capacity, builder);
Values.SP = this.fixString(builder.ToString().Replace(',', '.'));
goto Label_02EE;
case 0x1d:
builder = new StringBuilder(num3 + 1);
SendMessage(ptr3, 13, (IntPtr)builder.Capacity, builder);
Values.HP = builder.ToString().Replace(',', '.');
goto Label_02EE;
case 30:
builder = new StringBuilder(num3 + 1);
SendMessage(ptr3, 13, (IntPtr)builder.Capacity, builder);
Values.MP = builder.ToString().Replace(',', '.');
goto Label_02EE;
case 0x1f:
builder = new StringBuilder(num3 + 1);
SendMessage(ptr3, 13, (IntPtr)builder.Capacity, builder);
Values.EXP = builder.ToString();
goto Label_02EE;
case 0x20:
{
builder = new StringBuilder(num3 + 1);
SendMessage(ptr3, 13, (IntPtr)builder.Capacity, builder);
string[] strArray = builder.ToString().Split(new char[] { '\n' });
Values.Pos = this.fixString(strArray[0]);
Values.Loc = strArray[1];
goto Label_02EE;
}
case 0x26:
builder = new StringBuilder(num3 + 1);
SendMessage(ptr3, 13, (IntPtr)builder.Capacity, builder);
Values.Ip = builder.ToString().Split(new char[] { '(' })[1].Replace(')', ' ');
goto Label_02EE;
}
builder = new StringBuilder(num3 + 1);
SendMessage(ptr3, 13, (IntPtr)builder.Capacity, builder);
builder.ToString();
}
Label_02EE:
ptr3 = GetWindow(ptr3, GetWindow_Cmd.GW_HWNDNEXT);
}
IntPtr ptr4 = FindWindowEx(hwnd, IntPtr.Zero, "Static", null);
int capacity = (int)SendMessage(ptr4, 14, IntPtr.Zero, null);
StringBuilder lParam = new StringBuilder(capacity);
SendMessage(ptr4, 13, (IntPtr)lParam.Capacity, lParam);
string[] strArray3 = lParam.ToString().Split(new char[] { '\n' });
Values.EXPMin = this.fixString(strArray3[1].Replace('\t', ' '));
Values.EXPHour = this.fixString(strArray3[6].Replace('\t', ' '));
Values.EXPTotal = this.fixString(strArray3[13].Replace('\t', ' '));
Values.SPMin = this.fixString(strArray3[2].Replace('\t', ' '));
Values.SPHour = this.fixString(strArray3[7].Replace('\t', ' '));
Values.SPTotal = this.fixString(strArray3[14].Replace('\t', ' '));
Values.KillsMin = this.fixString(strArray3[3].Replace('\t', ' '));
Values.KillsHour = this.fixString(strArray3[8].Replace('\t', ' '));
Values.KillsTotal = this.fixString(strArray3[15].Replace('\t', ' '));
Values.Died = this.fixString(strArray3[0x10].Replace('\t', ' '));
Values.Gold = this.fixString(strArray3[0x11].Replace('\t', ' ').Replace(',', '.'));
Values.Drops = this.fixString(strArray3[0x12].Replace('\t', ' '));
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}