Originally Posted by
unbekannt1
Code:
hwnd = FindWindow(NULL, TEXT("World of Warcraft"));
is just working sometimes. And because i got the process handle out of the hwnd i hat sometimes the problem with reading memory. And now i am searching for an alternative of FindWindow. I know how to get process handle without window handle, but i need the hwnd to send keys to wow.
Alternative of FindWindow
Code:
DWORD wowpid = ...
HWND hWnd = GetTopWindow(NULL);
HANDLE WindowHandle = NULL;
while(hWnd)
{
DWORD pid;
DWORD dwTheardId = GetWindowThreadProcessId(hWnd, &pid);
if(pid == wowpid) ///<-- WoW PID here
{
WindowHandle = hWnd;
break;
}
Sleep(1);
hWnd = ::GetNextWindow(hWnd, GW_HWNDNEXT);
}