SWAPY icon indicating copy to clipboard operation
SWAPY copied to clipboard

`ctrl` variable is not assigned while generating click on toolbar button

Open vasily-v-ryabov opened this issue 9 years ago • 6 comments

It's reproduced on .\apps\MFC_samples\CmnCtrl1.exe. Just open "CToolBarCtrl" tab and run SWAPY.

Find "New" toolbar button and select Click method. The following code is generated:

import pywinauto

pwa_app = pywinauto.application.Application()
ctrl.Button(0).Click()

ctrl is not assigned here. Using ctrl.Button("New").Click() is also better than magic index. Text property is absent at the toolbar button description pane.

vasily-v-ryabov avatar Sep 29 '15 13:09 vasily-v-ryabov

Problem ctrl.Button("New").Click() also actual for ListView and TabControl. Works fine for ComboBox and Menu.

moden-py avatar Oct 04 '15 18:10 moden-py

The same bug for ComboBox item. See CmnCtrl3.exe combo box for reference. I've tried the latest build (x64, release): https://ci.appveyor.com/project/moden-py/swapy/build/1.0.30

Result:

import pywinauto

pwa_app = pywinauto.application.Application()
ctrl.Select('Black')

I expanded combo box items and chose "Select" for "Black" item.

vasily-v-ryabov avatar Oct 14 '15 18:10 vasily-v-ryabov

There is a bug in the code generation for VirtualSWAPYObject. The objects has no own init code they are accessed through the parent. For instance, combobox1.Select('Gray'). No any combobox_item1 var. Added checking for an empty init code. Fixed version - https://ci.appveyor.com/project/moden-py/swapy/build/1.0.32

moden-py avatar Oct 14 '15 21:10 moden-py

resolved in a8b85dd0cf4eb6e18d4824eb6fd0dc6b302b0637

moden-py avatar Oct 19 '15 10:10 moden-py

Using ctrl.Button("New").Click() is also better than magic index. If the "text" is not unique wrong item may be used. Use index access in such cases.

moden-py avatar Oct 23 '15 09:10 moden-py

The fix depends on #66

moden-py avatar Oct 27 '15 19:10 moden-py