I am writing a small bot with reading memory and using [Only registered and activated users can see links. Click Here To Register...] here from epvpers.
What i need is when process is selected from combo box that it read memory only from that selected process.
Problem is when bot is connected and process is selected it activate window and it should clear previous process and set new, and it works only for second process not for first one.
At the moment only second process selected works when process is changed, but first one never.
I think problem with this is because when you set KDMemory to get values it accept process name in class, but since all processes have same name it takes only one.
Here is code
What i need is when process is selected from combo box that it read memory only from that selected process.
Problem is when bot is connected and process is selected it activate window and it should clear previous process and set new, and it works only for second process not for first one.
At the moment only second process selected works when process is changed, but first one never.
I think problem with this is because when you set KDMemory to get values it accept process name in class, but since all processes have same name it takes only one.
Here is code
Code:
public partial class Form1 : Form
{
Process[] process;
static string processName = "Game.exe";
static string moduleName = processName;
static int mobHealth;
public Form1()
{
InitializeComponent();
}
private void btnConnect_Click(object sender, EventArgs e)
{
Process[] proc = Process.GetProcessesByName("game");
if (proc.Length != 0)
{
process = proc;
comboProcessList.Items.Clear();
for (int i = 0; i < proc.Length; i++)
{
comboProcessList.Items.Add("Game: " + (i + 1).ToString()); // text is jsut for visual display
}
comboProcessList.SelectedIndex = 0;
}
}
private void comboProcessList_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboProcessList.SelectedIndex != -1)
{
process = null;
Process[] proc = Process.GetProcessesByName("game");
if (proc.Length != 0)
{
process = proc;
SetForegroundWindow(process[comboProcessList.SelectedIndex].MainWindowHandle);
ShowWindow(process[comboProcessList.SelectedIndex].MainWindowHandle, SW_RESTORE);
}
}
}
private void ReadMobHealth()
{
try
{
var staticOffset = Entities.mobStaticOffset;
var offsetsValue = Entities.mobHealthOffetsValues;
var memoryDataValue = new KDMemory(processName, moduleName, staticOffset, offsetsValue, WINAPI.ProcessAccessRights.PROCESS_VM_READ);
foreach (var integer in memoryDataValue.GetInt32())
{
mobHealth = integer;
}
}
catch
{
Console.WriteLine("Error accessing target health");
}
}
}