the normal way is
Window window = application.GetWindows().Where(p=>p.Name == "name").First();
Button button = window.Get<Button>(SearchCriteria.ByAutomationID("id"));
But in your case it is difficult to identify the window.
Are all 3 Windows open the same time?
than search for text on window to be sure you have the correct one.
if you have 3 different Message Boxes at different times and you only want to click the OK button
use the first solution with empty name string