Potential SetFocus() issue - setfocus

I think SetFocus() still has some issues, follow below steps to reproduce:
'''Open Notepad and have it as Background window and Make Chrome or IE as Active Window and run the below script.
Observation: it does the first click on Chrome or IE before returning Notepad window and follows steps in script.'''
app = pywinauto.Application()
window = app.Window_(title_re='Untitled - Notepad')
window.SetFocus()
window['Edit'].ClickInput()
window.TypeKeys("Test")

Related

Taskbar icon appears blank (possibily due to a sticky cache)

I am having some issues with invalidating the Windows icon cache. I'm running a Win32 app that used to show the taskbar icon properly, however, after replacing the app's icon, the taskbar icon appears blank. It's interesting because when I use ALT-TAB, the correct icon does show up.
The window is created with WS_EX_APPWINDOW. I know it registers the correct icon because after pinning/unpinning it from the taskbar, the icon shows up as expected. I’ve gone through several attempts to solve this and have narrowed it down to refreshing the icon cache.
A few of the ways I tried to reset the icon cache:
Delete all icon cache files in folder:
%LOCALAPPDATA%/Microsoft/Windows/Explorer/, and restart explorer.exe
In Command Prompt: $ie4uinit.exe -show
Using Shell APIs to force the taskbar to refresh (SHChangeNotify)
Having gone through several different attempts and configuration techniques, the taskbar icon remains blank as shown above. I was wondering if there is another foolproof technique for resetting the Windows icon cache.

Making a lauched QT applicatioin get Focus in windows

Currently whenever my application starts it does not appear in the foreground. It appears on the taskbar but it does not get focus. I tried doing the following
application.setActiveWindow(&w);//w if my form widget
but this just makes it blink. Any suggestion on how I could set the focus to my application.

QDialog as Popup does not hide on Mac when clicking out of the main window

I have a basic QDialog with it's WindowFlags set to Qt::Popup so that it appears as a typical popup overlay.
On Windows, everything works great and if you click outside the main window or really anywhere else it goes away. But on Mac OSX, if you click the menu bar at the top or resize the window, the popup just stays where it is. I have absolutely no internal handling of the mouse enter/leave/move/press events for the popup, so the closing of it is not something I'm even handling... it's just automatic on Windows.
Any idea I can get it to close when the main application is no longer the current context on the system?
You may install native event filter and to close active popup dialog (QApplication::activePopupWidget()) when user will click out of main window. See the following answer for information how to install native filter.

WS_EX_TOOLWINDOW issue

On Dialog based application, if you create a new dialog(tool window), and you press alt-tab, you can see the main dialog, and the tool window is missing( that is ok, is what a tool window is made to do).
On sdi/mdi applications if you open a tool window and press alt-tab, the application disappear from task bar(mainframe too). And that is my problem . I want my mainframe to always appear on task bar when I press alt-tab, even if a tool window is opened.
Any idea is appreciated.
Thank you.

Popup windows are behind window but it is rendered front?

I am updating the webkit embeded to my program however I come across a new problem about popup windows (MessageBox or File/Folder chooser dialogs).
For instance, if I invoke a javascript alert() clicking on a link, the MessageBox is rendered in front of the webkit window and looks like it is clickable, however when it is clicked the webkit window gain the focus and the MessageBox goes back of the webkit window. After that everything works as usual.
This problem does not happens if I invoke the alert() with keyboard.
So given the clues, what could be the solution, any tips ?
OS: Win7
In win/webview.cpp WM_CANCELMODE message invokes a function. Comment out, problem is solved.