Questions tagged [setforegroundwindow]
45 questions
15
votes
2 answers
Python win32gui SetAsForegroundWindow function not working properly
I am trying to write a program that finds a window by searching for its title. Once it has found the window, it will attempt to bring it to front. I am using win32gui API to achieve this. I am able to get it to work for the most part, but for some…

Aasam Tasaddaq
- 645
- 4
- 13
- 23
7
votes
1 answer
Allow background application to set foreground window of different process
First off, I know this is a controversal discussion but I hope we can keep this technical.
I have an application which is started in background and I somehow want it to be able to activate/bring to focus a window in a different process. But calling…

divB
- 896
- 1
- 11
- 28
3
votes
1 answer
SetForegroundWindow: relationship between the ForegroundLockTimeout registry value and the SPI_GETFOREGROUNDLOCKTIMEOUT WinAPI parameter
Context:
This question is about how to control, through configuration, whether programmatic cross-process window activation (making a window the foreground window with the input focus) is allowed, via the SetForegroundWindow WinAPI function.
It…

mklement0
- 382,024
- 64
- 607
- 775
3
votes
1 answer
Win 10: Cmd can bring windows to foreground, but any other terminal can't(even if elevated). Why is this so?
I'm using pygetwindow to bring a window to the foreground, via it's title. And it works flawlessly if I run my python script from cmd(and PowerShell). But if I run it from any other terminal, say Alacritty, instead of coming to the foreground, the…

4amvim
- 115
- 1
- 9
3
votes
1 answer
How to use ShowWIndow() and SetForegroundWindow Correctly?
Here is what I want to do:
1)Open an application with username
2)Give some inputs
3)Open 2nd window for the application with different username
4)Give some inputs again
5)Switch to first application window, do somethg
6)Switch to second…

user3325210
- 163
- 3
- 12
3
votes
1 answer
SetForegroundWindow not working
I'm trying to launch an application and bring it to the front.
However, the application launches ok, then ends up going behind
the launching app.
Note that using a similar approach on an already-running minimized application works fine (that code…

radders
- 923
- 8
- 29
2
votes
1 answer
Bringing a window to foreground from a background process
My situation: A browser displays a webpage served by a locally running webserver. When the user clicks a button on the page, I would like to jump to another, possibly already running, application.
Working on Windows, I thought about processing the…

phimuemue
- 34,669
- 9
- 84
- 115
2
votes
1 answer
In Windows 8+, how do I bring Window Desktop App to foreground when Metro App in foreground via API?
My desktop application hook some hot keys eg: CTRL+SHIFT+F12, while the hot keys are pressed, it will bring my desktop application window into foreground or stay on top. But in Window 8 or 8.1, while it is in Window Start Screen or Metro App is…

franciz
- 23
- 2
1
vote
0 answers
SetForegroundWindow Windows 11 doesn't work
I use without problems a program that uses [SetForegroundWindow] in C# to bring the window to the foreground and activate in Windows 7 and Windows 10 operating systems, but now with Windows 11 it stopped working.
I need help, does anyone know how to…

André Luiz
- 11
- 1
1
vote
3 answers
Bring window to foreground refuses to work in windows 10
I have a powershell script that opens a program called CNCScreenE, saves a screenshot of this window, and then closes down the application.
it worked perfectly the first few times I ran it.
after those few times, now every time the program gets…

Philosophical
- 43
- 3
1
vote
1 answer
Create a WordPad instance and bring it to the top z-order, all from a non-foreground app
I am working with voice-operated software (Dragon from Nuance, or maybe Windows Speech Recognition (haven't tried that yet)).
In operation, the user (me) issues a voice command to make something happen. For this question, I am trying to write code…

Kevin
- 1,548
- 2
- 19
- 34
1
vote
2 answers
C++ program to bring a process to foreground if already running otherwise create a new process
I am trying to learn windows programming. I would like to launch an executable program.exe (say) from c++ code. I am able to achieve this by using CreateProcess() method in windows. However, my problem is if the process is already created and…

Akhilesh Pandey
- 868
- 8
- 18
1
vote
2 answers
How to implement a wpf launcher with SetForegroundWindow
I'm trying to implement a button command that launches a new WPF application the first time the user clicks the button and then (when the user clicks the button again) sends it to foreground, if it's already running. The whole thing is running on…
user6996876
1
vote
0 answers
Need to close 'save as' window in e2e test. SendKey using C#
I need to implement e2e automated test of printing to file as emulation of printing process using GUI. I have
Web application running under selenium and nunit. It presses Print button.
Printing application installed on computer. It prints data…

Artem A
- 2,154
- 2
- 23
- 30
1
vote
1 answer
Remote Desktop Connection - SetForeground Window not working
I have very similar problem to this one : SetForegroundWindow in Remote Desktop Connection
Everything works when I am connected and watching the RDC, but when I'm not.. Nothing happens.
I am using python and pywinauto, trying to use SendKeys method…

Muco
- 27
- 9