question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could not switch Tab Sheets on a window

See original GitHub issue

I have following items of an application written in Delphi, printed with print_control_indentifiers and I want to select the tab with title=“Units”:

TfrmExportSetup - 'Export Setup'    (L0, T0, R400, B600)
['Export SetupTfrmExportSetup', 'TfrmExportSetup', 'Export Setup']
child_window(title="Export Setup", class_name="TfrmExportSetup")
   | 
   | TPageControl - ''    (L6, T29, R394, B555)
   | ['TPageControl', 'pnlExportActive1TPageControl']
   | child_window(class_name="TPageControl")
   |    | 
   |    | TTabSheet - 'Maintenance'    (L10, T53, R390, B551)
   |    | ['MaintenanceTTabSheet', 'Maintenance', 'TTabSheet', 'TTabSheet0', 'TTabSheet1']
   |    | child_window(title="Maintenance", class_name="TTabSheet")
   |	|
   |    | TTabSheet - 'Units'    (L10, T53, R390, B551)
   |    | ['UnitsTTabSheet', 'TTabSheet3', 'Units']
   |    | child_window(title="Units", class_name="TTabSheet")

I tried different methods and none works. Some of the failures:

1.
Code:
self.export.child_window(class_name="TPageControl").menu_select("Units")
Error:
pywinauto.controls.menuwrapper.MenuInaccessible

2.
Code:
page_control = self.export.child_window(class_name="TPageControl")
page_control.child_window(title="Units", class_name="TTabSheet").click_input()
Error:
pywinauto.findwindows.ElementNotFoundError: {'title': 'Units', 'class_name': 'TTabSheet', 'top_level_only': False, 'parent': <win32_element_info.HwndElementInfo - '', TPageControl, 3742488>, 'backend': 'win32'}

3.
Code:
self.export.child_window(class_name="TPageControl").menu_bar_click_input("Units", self.app)
Error:
AttributeError: Neither GUI element (wrapper) nor wrapper method 'menu_bar_click_input' were found (typo?)

4.
Code:
page_control = self.export.child_window(class_name="TPageControl")
tab_list = page_control.descendants(class_name="TTabSheet")
tab_menu = tab_list[2]
print(tab_menu)
tab_menu.click_input()
Output:
It prints: hwndwrapper.HwndWrapper - 'Units', TTabSheet
But clicks on center on the window, not on the Units tab

I’ve added screenshots with the TPageControl and Units elements highlighted by Inspect.exe I’ve struggled a lot with this and couldn’t find the issue… Thanks in the advance for the help!

inspect_page_control inspect_units

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
fbarbu15commented, Apr 16, 2019

Issue solved! If anyone else has this problem I managed to find the solution by using TabControlWrapper. The solution that works:

from pywinauto.controls.common_controls import TabControlWrapper

page_control = self.export.child_window(class_name="TPageControl")
tab_control = TabControlWrapper(page_control.wrapper_object())
tab_control.select(2)
0reactions
yng80commented, Dec 25, 2021

Hi, do you know what do I need to change to get TabControlWrapper working for me? My goal is to paste “text” word in a specific tab of MobaXterm app.

kép

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to switch sheets in Excel - Microsoft Community
Unable to switch sheets in Excel. Hi, I recently bought an Asus Zenbook and my PgDn button is together with my down arrow...
Read more >
Can't move tabs, can't click on different windows open in ...
About a month or so ago I noticed I was no longer able to click and drag tabs I have opened in Google...
Read more >
Why can't I switch between workbooks in Excel 2010 using ...
I found the answer on another site,. In Excel Options -> Advanced -> Display -> Uncheck "Show all windows in the Taskbar",; Click...
Read more >
ALT TAB not Working: Diagnose & Fix in 7 Easy Steps
Alt-Tab not switching in Windows 10 – Several users reported that Alt-Tab doesn't switch windows on their Windows 10 PC. This can be...
Read more >
Fix Alt + Tab not toggle/working with Excel in Windows 10
No matter you have opened multiple Excel files and other program in Windows 10, pressing Alt+ Tab keys only swaps between just two...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found