Skip to content

Commit

Permalink
Merge pull request pywinauto#319 from vasily-v-ryabov/UIA
Browse files Browse the repository at this point in the history
  • Loading branch information
vasily-v-ryabov authored Feb 26, 2017
2 parents 6ec4b5b + 0deb748 commit 86070c6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pywinauto/controls/hwndwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,10 @@ def set_focus(self):
mouse.move(coords=(-10000, 500)) # move the mouse out of screen to the left

# change active window
win32gui.ShowWindow(self.handle, win32con.SW_RESTORE)
if self.is_minimized():
win32gui.ShowWindow(self.handle, win32con.SW_RESTORE)
else:
win32gui.ShowWindow(self.handle, win32con.SW_SHOW)
win32gui.SetForegroundWindow(self.handle)

# make sure that we are idle before returning
Expand Down
14 changes: 14 additions & 0 deletions pywinauto/unittests/test_hwndwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,20 @@ def testGetFocus(self):
self.dlg.Set.set_focus()
self.assertEqual(self.dlg.GetFocus(), self.dlg.Set.handle)

def test_issue_318(self):
self.dlg.restore()
self.dlg.minimize()
self.dlg.set_focus()
self.assertTrue(self.dlg.is_normal())
self.assertTrue(self.dlg.is_active())

self.dlg.maximize()
self.dlg.minimize()
self.dlg.set_focus()
self.assertTrue(self.dlg.is_maximized())
self.assertTrue(self.dlg.is_active())
self.dlg.restore()

def testSetFocus(self):
self.assertNotEqual(self.dlg.GetFocus(), self.dlg.Set.handle)
self.dlg.Set.set_focus()
Expand Down

0 comments on commit 86070c6

Please sign in to comment.