hello guys i need help pls i cant fix this , i work 2 days on it but icant fix it,
when i open the menu my mouse is working but when i close the menu and i wanna buy a smoke or nade it stuck in the buy menu

Code:
HRESULT __stdcall hkEndScene(IDirect3DDevice9* thisptr) {



	static bool mouse_enabled = false;
	thisptr->SetRenderState(D3DRS_COLORWRITEENABLE, 0xFFFFFFFF);
	bool is_renderer_active = renderer->IsActive();

	static auto paste = g_CVar->FindVar("cl_mouseenable");
	paste->SetValue(!is_renderer_active);

	if (is_renderer_active) {
		if (mouse_enabled) {
			mouse_enabled = false;
		}
	}
	else {
		if (!mouse_enabled) {
			mouse_enabled = true;
		}
	}

	ImGui::GetIO().MouseDrawCursor = is_renderer_active;

	if (!is_renderer_active)
		return oEndScene(thisptr);

	ImGui_ImplDX9_NewFrame();

	NewMenu();

	ImGui::Render();

	return oEndScene(thisptr);
}

typedef HRESULT(_stdcall *Present_T)(void*, const RECT*, RECT*, HWND, RGNDATA*);
Present_T oPresent;
HRESULT _stdcall hkPresent(LPDIRECT3DDEVICE9 pDevice, RECT* pSourceRect, RECT* pDestRect, HWND hDestWindowOverride, RGNDATA* pDirtyRegion)
{
	if (!renderer->IsReady())
	{
		renderer->Initialize(FindWindowA("Valve001", NULL), pDevice);
	}
	static bool mouse_enabled = false;
	pDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 0xFFFFFFFF);
	bool is_renderer_active = renderer->IsActive();


	static auto paste = g_CVar->FindVar("cl_mouseenable");
	paste->SetValue(!is_renderer_active);

	if (is_renderer_active) {
		if (mouse_enabled) {
			mouse_enabled = false;
		}
	}
	else {
		if (!mouse_enabled) {
			mouse_enabled = true;
		}
	}

    ImGui::GetIO().MouseDrawCursor = is_renderer_active;

    if (!is_renderer_active)
        return oPresent(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);

    ImGui_ImplDX9_NewFrame();

    NewMenu();

    ImGui::Render();

    return oPresent(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
}
can you help me pls

greetz rehaxxor