System.Windows.Automation is extremely slow

System.Windows.Automation is EXTREMELY slow. System.Windows.Automation is full of bugs. It may not return all children of an AutomationElement, which is a very severe bug. Apart from that the implementation is not thread safe. System.Windows.Automation is deprecated. Do not use it! In the MSDN you find the following note: UI Automation was first available in Windows … Read more

Run the current application as Single Instance and show the previous instance

I propose you a different method, using a combination of the System.Threading.Mutex class and UIAutomation AutomationElement class. A Mutex can be, as you already know, a simple string. You can assign an application a Mutex in the form of a GUID, but it can be anything else. Let’s assume this is the current Application Mutex: … Read more

Python – Control window with pywinauto while the window is minimized or hidden

The problem is here: Wizard[‘Create Shortcut on Desktop’].wait(‘enabled’).check_by_click() check_by_click() uses click_input() method that moves real mouse cursor and performs a realistic click. Use check() method instead. [EDIT] If the installer doesn’t handle BM_SETCHECK properly the workaround may look so: checkbox = Wizard[‘Create Shortcut on Desktop’].wait(‘enabled’) if checkbox.get_check_state() != pywinauto.win32defines.BST_CHECKED: checkbox.click() I will fix it in … Read more

How can I use EnumWindows to find windows with a specific caption/title?

Original Answer Use EnumWindows and enumerate through all the windows, using GetWindowText to get each window’s text, then filter it however you want. [DllImport(“user32.dll”, CharSet = CharSet.Unicode)] private static extern int GetWindowText(IntPtr hWnd, StringBuilder strText, int maxCount); [DllImport(“user32.dll”, CharSet = CharSet.Unicode)] private static extern int GetWindowTextLength(IntPtr hWnd); [DllImport(“user32.dll”)] private static extern bool EnumWindows(EnumWindowsProc enumProc, IntPtr … Read more

How to switch to new window in Selenium for Python?

You can do it by using window_handles and switch_to.window method. Before clicking the link first store the window handle as window_before = driver.window_handles[0] after clicking the link store the window handle of newly opened window as window_after = driver.window_handles[1] then execute the switch to window method to move to newly opened window driver.switch_to.window(window_after) and similarly … Read more