Answer the question
In order to leave comments, you need to log in
How to bring a windows window to the front?
There is a script in which you need to bring the telegram window to the foreground, I actively used pyautogui, but I didn’t find such a function there, I couldn’t figure it out with pywinauto, maybe someone here will advise how to implement it.
Answer the question
In order to leave comments, you need to log in
You need to install Pywin32 (win32api)
FindWindow
SetForegroundWindow
ShowWindow
hwnd = win32gui.FindWindow(None,"Telegram")
win32gui.ShowWindow(hwnd, win32con.SW_NORMAL)
win32gui.SetForegroundWindow(hwnd)
Or with pywinauto:
from pywinauto.application import Application
app = Application().connect(title_re="Telegram")
app.window(title_re='Telegram \(\d+\)').set_focus()
But what if I need, for example, just bring to the "Foreground" a window with a name such as "notepad" in windows 10, if it's not difficult, please write the whole code and not a cut from the code (as Alexander wrote in the first answer), if it's even possible on Python language (What is obvious to professionals is not obvious to beginners, and professionals will not look for answers to such questions)
This code does not expand the Notepad window in any way, what am I doing wrong?
import win32gui
import FindWindow
import SetForegroundWindow
import ShowWindow
hwnd = win32gui.FindWindow(None,"notepad")
win32gui.ShowWindow(hwnd, win32con.SW_NORMAL)
win32gui.SetForegroundWindow(hwnd)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question