im trying to write a small app, that starts runesofmagic and gets its hwnd.
the hwnd will then get passed to bot.lua.
passing over the hwnd to bot.lua is not the problem, but i cant get the hwnd.
this is what i tried:
Code: Select all
#include <iostream>
#include <windows.h>
using namespace std;
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM param)
{
DWORD id = GetWindowThreadProcessId(hwnd, NULL);
if (id == (DWORD)param)
{
//do whatever we want to do
cout << hwnd << endl;
return false;
}
return true;
}
int main ()
{
char path[] = "myapp.exe";
PROCESS_INFORMATION pi;
CreateProcess(
path,
NULL, // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
NULL, // Pointer to STARTUPINFO structure.
&pi // Pointer to PROCESS_INFORMATION structure.
);
Sleep(100);
::EnumWindows(&EnumWindowsProc, pi.dwThreadId);
system("pause");
return 0;
}
any hints or suggestions?
thanks in advance.
greetings depp