this sample (copy paste from a component i written sometime ago) is useful and shows how to access 64 slots, divided into 4 bags, distributed as 4 rows, 4 columns accessed sequentially.
dont ask me for the component... this section is meant for coders.
Code:
byte[] buffer = new byte[4];
uint bytesRead = 0;
int address = Convert.ToInt32("0089afc4", 16);
ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);
address = BitConverter.ToInt32(buffer, 0) + 1184; //0x4a0 == 1184 (int)
ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);
address = BitConverter.ToInt32(buffer, 0) + 68; //0x44 == 68
ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);
address = BitConverter.ToInt32(buffer, 0) + 12; //0xc == 12(int)
ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);
//from here on we access the bag slots which are stored in a sequential array with 4 bytes
//offset from the previous slot
int firstSlotInBagAddress = BitConverter.ToInt32(buffer, 0);
for (int i = 0; i < 4; i++)
{
Thread.Sleep(1000);
//press bag i tab
mouseClick(bag, true);
// cleanBag(i,firstCell,trash,cellHeight); //clean current bag
bag.x = bag.x + cellHeight;
////////////////////////////////////// clean bag i
int row = 0;
int col = 0;
Thread.Sleep(500);
for (int c = 0; c < 16; c++)
{
row = c / 4;
col = c - row * 4;
///////////////////// obtain the item id in current cell
address = firstSlotInBagAddress + (c+i*16) * 4;
ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);
address = BitConverter.ToInt32(buffer, 0) + 64; //0x40 == 64
ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);
address = BitConverter.ToInt32(buffer, 0) + 48; //0x30 == 48
ReadProcessMemory(targetProcess.Handle, (IntPtr)address, buffer, 4, ref bytesRead);
int id = BitConverter.ToInt32(buffer, 0);
//////////////////////////check current if we should delete it or not
if (id==0/*empty cell*/ || keepItemIDs.Contains(id))
continue; //dont delete, check the next cell
////////////////////
Point cell = new Point(firstCell.x+cellHeight*col, firstCell.y+cellHeight*row);
// for (int i = 0; i < 16; i++)
// {
//delete current cell
//simple: button down at cell point, up at trash point, then cick confirm
uint wparam = 0;
uint lparam = 0;
wparam = 0x00000001; //left button
lparam = ((uint)cell.y << 16) | (uint)cell.x; //x to the lower word, y to the higher
PostMessage(targetProcess.MainWindowHandle, WM_LBUTTONDOWN, wparam, lparam);
Thread.Sleep(500);
lparam = ((uint)trashPoint.y << 16) | (uint)trashPoint.x; //x to the lower word, y to the higher
PostMessage(targetProcess.MainWindowHandle, WM_LBUTTONUP, wparam, lparam);
Thread.Sleep(500);
//confirm
mouseClick(confirmButtonPoint, true);
Thread.Sleep(500);
}
}
its easier to learn by example.
k, thats my last post in this thread, have fun.