There are 2 windows desktop apps such as A.exe and B.exe.
They don’t have any socket communication.
Assuming that a user sees A window for now and he wants to switch into B window without closing A window and open B Window.
I want to put SWITCH button in A. In this case, is there any way for us to switch to B window? Actually, no code relation between A and B.
When a user clicks the SWITCH button, I want to show B window in front.
AppActivate(title as String, unused as Boolean = false)
If they are the same and you want to find the window based on the process name (a.exe or b.exe) then its a bit more complicated as you need to enumerate all processes:
A.exe just has one Title.
B.exe has 10 Titles per its menu.
I can make A.exe(Window) in front easily by calling AppActivate method as there is only one Title I can use.
However, I am not sure how I can make B.exe front using AppActivate because there are many Titles to be used, at a specific time there is only one though.
Should I run the AppActivate with for – loop 10 times until the method finds the one Title?
Have a look here, there is a zip you can download with some of the code in that you can use/modify to enumerate the list.
With a slightly modified routine, you can find the filename you use then bring it to the front using AppActivate from the github link I posted earlier.
If you need to use it, I would change the memoryblock and nSize in ListAppsRunningWin32 to 32767 to get around any possible path name size errors. You also only need to init it once as the string will always be null terminated, so I would take the init out of the loop.