How to launch an application in the foreground?

x64 Replacement/Alternative to Microsoft's IntelliMouse application.
Forum rules
Please read the forum rules before posting for the first time.
The more information you can provide, the quicker and more accurately someone can help.
NOTE: To reduce spam, new users can not post links, files or images until they have at least 4 posts.
Post Reply
User avatar
PhilRocks
New User
Posts: 6
Joined: Fri May 12, 2023 10:45 pm

How to launch an application in the foreground?

Post by PhilRocks »

XMBC Version: 2.20.5
Installed or Portable version: Scoop
Windows Version: 11
Mouse Information (brand/model): Trackball
Relevant Computer Information (CPU, RAM etc): Yes :)
Did the problem occur after an upgrade of XMBC? (If so, from what version?): No
Did the problem occur after a Windows update/upgrade? (If so, from what version?): No
How long have you used XMBC?: Years
What language and keyboard layout do you use in Windows?: Eng

I have a button chord configured to open a text file. If another app is open, and I press the chord, the text editor is always opened in the background. This requires that I then reveal the taskbar (normally have it hidden) and click the taskbar icon for the text editor, which defeats the convenience.

I'm currently using Notepad++ (64-bit portable) for the text editor.

I set the button chord to open the text file via the application launch action, and set its launch string to:
c:\notepad\notepad++.exe "c:\text\file.txt"

I also tried simply setting the launch string to just:
"c:\text\file.txt"

Both have the same result. Notepad++ always opens in a background window behind the current foreground window.

I'm thinking either (1) I'm doing something wrong, or (2) XMBC will really benefit from a "foreground application launch" action.
User avatar
phil
Site Admin
Posts: 7875
Joined: Sun Apr 06, 2003 11:12 pm

Re: How to launch an application in the foreground?

Post by phil »

Simple answer, I'm not sure. Windows goes quite some way to stop applications stealing foreground, but normally when an application is launched, it would launch in the foreground, so I'm not sure why that is not the case when launching from XMBC.

On my laptop (Win11), using the "Run Application" option on the dropdown for me, with Notepad++ (but no arguments, just opening notepad++) opens it in the foreground as expected, so maybe either I'm missing something, or adding the arguments is causing the problem, or maybe its doing it in a chord rather than just a button (I doubt it but will have to check). I will have to find some time to have a play around and see if I can do anything to recreate this... But right now I'm away for Christmas/New Year so that's going to take me some time to get around to. If I haven't done this by early January, remind me by posting again to this thread (I should be back home on the 4th or 5th)

Could you possibly export your settings and send them to me in a private message here, so I can test with your exact configuration and see if there is something in the configuration that differs from what I have just checked here?

Side note, what does "Installed or Portable version: Scoop" mean? Its quite important to know if you are using the installed version or the portable version, as the portable version has some limitations (particularly when working with UAC elevated permissions and some system keystrokes - maybe not relevant here but still useful information). The questions in the post topic may seem silly/pointless but it provides very useful context, not least the technical level of expertise I need to direct my responses (or maybe in this case, sarcasm :)) too!
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 11 x64 24H2, AMD Ryzen 9950x3D, MSI x870E Tomahawk, 64GB DDR%,
nVidia RTX 2070s (still lol)
User avatar
PhilRocks
New User
Posts: 6
Joined: Fri May 12, 2023 10:45 pm

Re: How to launch an application in the foreground?

Post by PhilRocks »

phil wrote: Mon Dec 23, 2024 8:16 pm Simple answer, I'm not sure...

... But right now I'm away... (I should be back home on the 4th or 5th)
Enjoy your holiday Phil! :D

phil wrote: Mon Dec 23, 2024 8:16 pm Could you possibly export your settings and send them to me in a private message here, so I can test with your exact configuration and see if there is something in the configuration that differs from what I have just checked here?
Yes, definitely. I'm not as fortunate as you... I'll be slogging over the keyboard until the end of the year. Hopefully will be able to convince myself to take a break in there sometime. I'll make a note to send it to you... and if that note gets shuffled to the bottom of the desk, please kindly remind me!
phil wrote: Mon Dec 23, 2024 8:16 pm Side note, what does "Installed or Portable version: Scoop" mean? Its quite important to know if you are using the installed version or the portable version, as the portable version has some limitations (particularly when working with UAC elevated permissions and some system keystrokes - maybe not relevant here but still useful information). The questions in the post topic may seem silly/pointless but it provides very useful context, not least the technical level of expertise I need to direct my responses (or maybe in this case, sarcasm :)) too!
I wish my response to that question was quality humour or at least enjoyable sarcasm, but in this case, it was literal. Scoop is a popular command line installer for Windows. See https://scoop.sh/ and https://github.com/ScoopInstaller

Here is the XMBC page for Scoop:
https://scoop.sh/#/apps?q=xmouse

And here is XMBC's Scoop manifest:
https://github.com/ScoopInstaller/Extra ... ntrol.json

Enjoy yourself! :cheers:
User avatar
phil
Site Admin
Posts: 7875
Joined: Sun Apr 06, 2003 11:12 pm

Re: How to launch an application in the foreground?

Post by phil »

RE: Scoop....
Well you learn something new everyday :).
I knew about winget and chocolaty, scoop is a new one to me - will have to have a look!

Looking at the manifest, it uses the portable version. So I will check the Open/Run with the portable version too when I get a chance...

I wonder if the maintainer of that scoop manifest (not clear to me who that is as it seems multiple people have submitted changes) knows the limitations of the portable version, where it does not run fully as a "Windows Accessibility Tool" unless it runs from either the \Program Files, \Program Files (x86) or \Windows\System folder (a limitation that Microsoft imposes).

When not running as an accessibility tool (and not running as administrator), XMBC can not send certain protected keystrokes (like ctrl+alt+del, win+x etc.) and can not override the "bring window to foreground (for activating windows on mouse hover). Also it can not operate with elevated processes when not running elevated (as admin) itself.

I don't think that "not bring windows to the foreground" thing affects the RUN/Open command as that just calls the Windows API to launch apps.... But I will have to check, as its possible it tries to force foreground after running the app (which will not work in "portable" mode). As Scoop is an "installer" and its using the portable version for convenience, it might be worth modifying the manifest to "install" it under the program files folder, and use the same configuration as the installed version. I guess it does not use the installer as there isn't a silent install option, which might be worth looking at too!
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 11 x64 24H2, AMD Ryzen 9950x3D, MSI x870E Tomahawk, 64GB DDR%,
nVidia RTX 2070s (still lol)
Post Reply