<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def getForegroundWindow(self):
 """ Returns a handle to the window in the foreground """

        active_app = NSWorkspace.sharedWorkspace().frontmostApplication().localizedName()
        for w in self._get_window_list():
            if "kCGWindowOwnerName" in w and w["kCGWindowOwnerName"] == active_app:
                return w["kCGWindowNumber"]