In my project, i can get the window which mouse is on, and i can use AXUIElementSetAttributeValue(element, kAXFrontmostAttribute, kCFBooleanTrue); to make the
AXUIElementSetAttributeValue(element, kAXFrontmostAttribute, kCFBooleanTrue);