Skip to content

Commit

Permalink
Support Afx Toolbar button Rectangle() by index pywinauto#104.
Browse files Browse the repository at this point in the history
  • Loading branch information
vasily-v-ryabov committed Oct 22, 2015
1 parent 449318a commit b7e30a8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 26 deletions.
34 changes: 10 additions & 24 deletions pywinauto/controls/common_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2064,13 +2064,16 @@ def Rectangle(self):
rect = win32structures.RECT()

remote_mem.Write(rect)

self.toolbar_ctrl.SendMessage(
win32defines.TB_GETRECT,
self.info.idCommand,
remote_mem)

self.toolbar_ctrl.SendMessage(win32defines.TB_GETRECT,
self.info.idCommand,
remote_mem)
rect = remote_mem.Read(rect)

if rect == win32structures.RECT(0, 0, 0, 0):
self.toolbar_ctrl.SendMessage(win32defines.TB_GETITEMRECT,
self.index,
remote_mem)
rect = remote_mem.Read(rect)

del remote_mem

Expand Down Expand Up @@ -2353,24 +2356,7 @@ def TipTexts(self):
def GetButtonRect(self, button_index):
"Get the rectangle of a button on the toolbar"

button_struct = self.GetButton(button_index)

remote_mem = RemoteMemoryBlock(self)

rect = win32structures.RECT()

remote_mem.Write(rect)

self.SendMessage(
win32defines.TB_GETRECT,
button_struct.idCommand,
remote_mem)

rect = remote_mem.Read(rect)

del remote_mem

return rect
return self.Button(button_index).Rectangle()

#----------------------------------------------------------------
def GetToolTipsControl(self):
Expand Down
4 changes: 2 additions & 2 deletions pywinauto/timings.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
* before_closeclick_wait (default .1)
* closeclick_retry (default .05)
* closeclick_dialog_close_wait (default .05)
* closeclick_dialog_close_wait (default .5)
* after_closeclick_wait (default .2)
* after_windowclose_timeout (default 2)
Expand Down Expand Up @@ -125,7 +125,7 @@ class TimeConfig(object):

'before_closeclick_wait' : .1,
'closeclick_retry' : .05,
'closeclick_dialog_close_wait' : .05,
'closeclick_dialog_close_wait' : .5,
'after_closeclick_wait' : .2,

'after_windowclose_timeout': 2,
Expand Down
7 changes: 7 additions & 0 deletions pywinauto/unittests/test_common_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,13 @@ def testGetBand(self):
def testGetToolTipsControl(self):
self.assertEquals(self.ctrl.GetToolTipsControl(), None)

def testAfxToolBarButtons(self):
"Make sure we can click on Afx ToolBar button by index"
self.dlg.StandardToolbar.Button(1).Click()
self.app.Window_(title='Open').Wait('ready')
self.app.Window_(title='Open').Cancel.ClickInput()
self.app.Window_(title='Open').WaitNot('visible')


class DatetimeTestCases(unittest.TestCase):
"Unit tests for the DateTimePicker class"
Expand Down

0 comments on commit b7e30a8

Please sign in to comment.