-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
window.close() does not work #48
Comments
Maybe take a look and ask at PyGetWindow fork |
Hi! I have tested your code on my own system (Windows 10) and works perfect. Check this:
And this is the output:
Chrome closes immediately, without any issue. Can you please share which is the content of "title" variable in your code? Happy new year!!! |
Hello and happy new year, Actually my title is an iterable thing. But when I assign it to
Once this mysterious thing was working. I can find the right window red-bloodedly and I am able to print. many thanks. note: window.minimize() does not work either |
Hello again, Right before the relevant code above. I have placed another :
and it worked for the first. But if we repeat the operation in the same code, It doesn't work for the second window. I don't know why? For your information: I got success closing the second window by finding out the pid and killing it.. |
Hi again! I think the problem is that the code runs too fast, not leaving enough time for the Window Manager to refresh the list of open windows. Therefore, it's retrieving the first window again (though it was just closed). You can either wait a little bit (time.sleep(something), but not a good strategy anyway because "something" value is unknown), store previous windows ID's and discard them (not using [0], I mean, but looping until finding a new one), or change the strategy. Check this:
Your code was not working for me either. This other alternative closes both windows. In addition to that, this is not correct:
If you try this as a very simple example:
This would be the output:
This is because you are creating a totally new iter() object every single time. I am not sure if you actually need an iter() object (you can check my code, in which you can loop over an iterable object just using "for... in..."). If you already need it, then create the iter() object once, and use next() alone, like this:
|
Hello. I just tried to use the module, but it doesn't work fully.
Console output: |
Hi! Not sure what can be happening in your case. Is 'L-Connect 3' a, let's say, normal/regular/standard window? In the meantime, I would suggest you give a try to PyWinCtl module (a fork from PyGetWindow module):
then, try this:
|
Hello, once I was able to close the choosen windows. I have changed the platforms, now I am not able to do that.
import pygetwindow as gw
window = gw.getWindowsWithTitle(title)[0]
print(window)
window.close()
the result of
print(window)
is below. Therefore, I understand that this is the right object to close.<Win32Window left="10", top="10", width="945", height="1020", title="some title - Google Chrome">
but
window.close()
does not work. Nothing happens.Is there any way to test it for further details?
The text was updated successfully, but these errors were encountered: