Skip to content
This repository has been archived by the owner on Jul 31, 2018. It is now read-only.

ctrl variable is not assigned while generating click on toolbar button #44

Open
vasily-v-ryabov opened this issue Sep 29, 2015 · 6 comments
Labels

Comments

@vasily-v-ryabov
Copy link

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.

@moden-py
Copy link
Contributor

moden-py commented Oct 4, 2015

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

@vasily-v-ryabov
Copy link
Author

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.

@moden-py
Copy link
Contributor

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
Copy link
Contributor

resolved in a8b85dd

@moden-py
Copy link
Contributor

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 moden-py reopened this Oct 23, 2015
@moden-py
Copy link
Contributor

The fix depends on #66

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants