Skip to content

Commit

Permalink
new way of detecting GTASA window instead of relying on window title
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyrAhmady committed Mar 28, 2021
1 parent ab99069 commit dc46698
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions gta-samp-mouse-only/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,39 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReser

void Start()
{
bool Initialized = false;
HWND SAMPWnd = NULL;
while (true)
while (!Initialized)
{
SAMPWnd = FindWindow(NULL, L"GTA:SA:MP");
#ifdef _DEBUG
AllocConsole();
freopen("CONOUT$", "w", stdout);
#endif
SAMPWnd = FindWindow(L"Grand theft auto San Andreas", NULL);
if (SAMPWnd)
{
SAMPHandle = reinterpret_cast<DWORD>(GetModuleHandle(L"samp.dll"));
if (SAMPHandle)
LOG << "Found GTA San Andreas window";
while (true)
{
pGame = *(DWORD **)(SAMPHandle + 0x21A10C);
pNetGame = *(CNetGame **)(SAMPHandle + 0x21A0F8);
if (pNetGame == nullptr) continue;
break;
SAMPHandle = reinterpret_cast<DWORD>(GetModuleHandle(L"samp.dll"));
if (SAMPHandle)
{
pGame = *(DWORD **)(SAMPHandle + 0x21A10C);
pNetGame = *(CNetGame **)(SAMPHandle + 0x21A0F8);
if (pNetGame == nullptr)
{
Sleep(200);
continue;
}
LOG << "Found an instance of CGame and CNetGame";
Initialized = true;
break;
}
}

};
Sleep(200);
}

#ifdef _DEBUG
AllocConsole();
#endif

freopen("CONOUT$", "w", stdout);

while (true)
{
// check if focused window is GTA SA window or not, if not, ignore key checks
Expand Down

0 comments on commit dc46698

Please sign in to comment.