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.

'operation (e.g. mouse click) when window not focused' BUG

See original GitHub issue

Expected Behavior

Until windows 10 latest update (19043.1237) pywinauto ‘background processing’ worked like charm. So, e.g. it was possible to click on a window even if it wasnt focused and set foreground with code like:

app = Application()
app.connect(handle=target_window)
app.window(title=window_title).click(button='left', coords=(int(x_cor),int(y_cor)))  

Actual Behavior

Now, the same code stopped working, to be exact: the code always set the window focused and foreground, 😦 I am not sure how many people affected by this in practice, but I assume this is a relatively large bug/correction would be great to have fixed if possible.

Steps to Reproduce the Problem

  1. install windows version updates 19043.1237 or higher.
  2. run a simple code like above and and bug reproduced.

Short Example of Code to Demonstrate the Problem

Shown above.

Specifications

  • Pywinauto version: 0.6.8
  • Python version and bitness: 3.9.7
  • Platform and OS: Windows 10 19043.1237

BIG thank you for your help and time to look into this

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
madtatu-developmentcommented, Oct 10, 2021

BIG thanks for your response, time and help! Actually, I love to keep things simple, so I do use it as simple as possible, here is the real code:

`# ---------------------- mouse click (WITHOUT the need of make it active and foreground) def left_click (x_coordinate, y_coordinate):

try:                        

    target_window = win32gui.FindWindow(None, ("Google - Google Chrome"))

    app = Application()
    app.connect(handle=target_window)
    app.window(title=window_title).click(button='left', coords=(x_coordinate,y_coordinate)) 

except (RuntimeError, ElementNotFoundError, BaseException): 
        
    print ("Target window became unavailable!")

    os._exit(1) `

Steps to reproduce the issue: 1) Open Chrome, I have version: Screenshot 2021-10-10 141539

2) open www.google.com or any other website, the critical thing to choose simple website to make sure it doesnt has nested content (eg. typical in online games) as thats cant be clicked. So just something simple website for testing.

3) open notepad and maximize it.

4) Now execute the code above in python with setting any x,y coordinate,

When the click happen: Chrome window will come forward, front of notepad window.

Does it happen at your side as well ?

0reactions
madtatu-developmentcommented, Oct 21, 2021

Appreciate your response, fully understanding, looking forward to your feedback in November. Once again, BIG thanks for letting me know and lots of strength for handling the overload.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mouse deselects active window, wont respond until ctrl alt del
The problem that I'm having is that my mouse sporadically "unfocuses" my current active window when I click, and will not interact with ......
Read more >
Unable to click on windows, mouse clicks defocus all windows
Note: you can usually get usability for a while by pressing just ctrl + esc or ctrl + alt + delete and then...
Read more >
Bug #1131428 “Loss of correct mouse focus (interference with ...
The bug seems to be due to an interference between the application and the desktop window manager (DWM) or an application accessing to...
Read more >
26213 – window focus for mouse stuck (was: after some time ...
A minor addition to his description: - Once you left-click in a window which has no context menu on a right-click, you are...
Read more >
c# - programmatically mouse click in another window
What program are you trying to click on? Some programs (mostly games) have mechanisms to handle what you are trying to do and...
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