It is currently August 8th, 2020, 9:30 am

Launching programs behaviour

Report bugs with the Rainmeter application and suggest features.
edo2313
Posts: 4
Joined: May 4th, 2020, 11:05 pm

Launching programs behaviour

Post by edo2313 »

Hi!
I noticed that OBS couldn't record my apps and games and I found out that the problem is with how Rainmeter launches programs. This means that if I start what I want from the exe or from the windows start menu it works without issues.

I had this same problem when using a program that makes a sort of overlay for League of Legends, it didn't detect the game was running when I opened it from my Rainmeter skin (btw, I use Circle Launcher but it is the same with other skins and also when launching using other methods like RunCommand).
The developer of that program made me run

Code: Select all

wmic process where "name like 'program.exe' " get commandline
(where program.exe is the name of the process)
and it didn't output when I opened that with the skin, while it outputs the path to the exe when opening from the start menu (and this is the intended behaviour). So it seems like Rainmeter spawns processes in a strange way or it clears the arguments for them.

I don't think this should be the intended behaviour, opening a program from the start menu if you want to use OBS or something else with it makes the idea of a launcher skin pointless...

Thanks in advance,
Edo :)

(oh btw, I am free to test things so just ask)
User avatar
Brian
Developer
Posts: 2044
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Launching programs behaviour

Post by Brian »

OBS capturing keeps coming up in these forums. We almost need a "sticky" thread to address it.
https://forum.rainmeter.net/viewtopic.php?f=4&t=35090&p=175037#p175037

So, in your case, you are asking about "how" Rainmeter launches a program. Well the 2 main ways are: a regular action or RunCommand. You could even use Lua or the FileView plugin.

RunCommand creates a pipe so that any output from the launched program will redirect to the plugin so Rainmeter can "use" it. It does this by launching the program as a "child" process of Rainmeter. This means the launched program *may* have the same attributes as Rainmeter (like WS_EX_TOOLWINDOW, which OBS skips). I say *may* because programs can change their attributes by themselves, so it's possible that a RunCommand launched program might not have the same attributes. This can't be changed since it the entire purpose of the plugin.

The most common way to launch a program in Rainmeter is just using a plain old action. LeftMouseUpAction=["C:\path\to\your\program.exe"]. In this case, Rainmeter just passes the "command" to the Windows shell (via ShellExecuteEx) - then Windows runs the command. I don't believe Windows attaches any special attributes to the launched program. The FileView plugin also launches programs (or any file) via ShellExecuteEx as well. I would be surprised if launching a program in this manner effects the way OBS captures the window in question.


At the end of the day, Rainmeter doesn't do anything special (outside of the feature scope) to any commands to launch external programs. OBS seems to have a very specific set of criteria to capture a window. Rainmeter doesn't fall into this category, so I am not surprised they have issues with other types of window styles. Seems like a design flaw with OBS to exclude any type of window.

-Brian
oZone
Posts: 133
Joined: May 14th, 2018, 4:46 pm

Re: Launching programs behaviour

Post by oZone »

I don't use OBS but IIRC OBS cannot capture child windows and Rainmeter launches programs as child processes, so maybe this can cause issues.
edo2313
Posts: 4
Joined: May 4th, 2020, 11:05 pm

Re: Launching programs behaviour

Post by edo2313 »

Ok so actually it is what I thought. But you say that the plain action LeftMouseUp=["path/to/exe.exe"] shouldn't spawn the processes as child because it doesn't care about the output... Which is instead what RunCommand does because it is designed for that purpose.
The thing is that even in the "normal way" (the skin uses that) it seems to spawn the processes as child or in a way that makes them unaccessible from other programs (as I wrote earlier, parameters such as CommandLine aren't present).
Shouldn't launching a program using a skin with the plain action and launching using the start menu or the exe be the exact same?
If not, is there a way to do so? I tried RunCommand to do "start path/to/exe.exe" (as the start command spawns another process that is independent from the one that is launching it, in my limited knowledge) and it also didn't work.

Sorry for bothering you, but I think I'm not the only one in the world with this problem

Edo
User avatar
Brian
Developer
Posts: 2044
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Launching programs behaviour

Post by Brian »

oZone wrote:
May 5th, 2020, 6:24 am
I don't use OBS but IIRC OBS cannot capture child windows and Rainmeter launches programs as child processes, so maybe this can cause issues.
This is somewhat misleading. RunCommand does this, but regular actions do not (unless a folder is being opened). Here is where an action "runs" a command (like an .exe, opening a folder, or opening some file).
https://github.com/rainmeter/rainmeter/blob/master/Library/CommandHandler.cpp#L496-L516

ShellExecuteEx states the following for the parameter hwnd:
docs.microsoft.com wrote:Type: HWND
Optional. A handle to the parent window, used to display any message boxes that the system might produce while executing this function. This value can be NULL.
What this is saying is, if you use a window handle (hwnd), then the launched program/file/folder/etc. will be ran as a child process. If you use NULL, it is not ran as a child process. So, LeftMouseUpAction=["C:\someprogram.exe"] is not launched as a child process.




edo2313 wrote:
May 5th, 2020, 9:34 am
Sorry for bothering you, but I think I'm not the only one in the world with this problem
You aren't bothering anyone, I get the frustration with issues like these. Yes, this keeps coming up, but the real issue here is OBS and how they "determine" which windows are capturable. They seem to be looking at certain criteria such as the WS_EX_TOOLWINDOW window style and now possibly the "command line" setting on launched programs (and possibly more requirements). Their criteria excludes perfectly valid "drawn" windows. Their software didn't even detect Google Chrome browser in the past (I am not sure about now).

I am not really sure what else to say. We launch programs one of the most standard ways possible.

-Brian

PS - When opening notepad like this: LeftMouseUpAction=["notepad"], it clearly sets "command line". Here is what Task Manager shows:
Forum.ShellExecuteEx.png
You do not have the required permissions to view the files attached to this post.
edo2313
Posts: 4
Joined: May 4th, 2020, 11:05 pm

Re: Launching programs behaviour

Post by edo2313 »

You aren't bothering anyone, I get the frustration with issues like these. Yes, this keeps coming up, but the real issue here is OBS and how they "determine" which windows are capturable. They seem to be looking at certain criteria such as the WS_EX_TOOLWINDOW window style and now possibly the "command line" setting on launched programs (and possibly more requirements). Their criteria excludes perfectly valid "drawn" windows. Their software didn't even detect Google Chrome browser in the past (I am not sure about now).

I am not really sure what else to say. We launch programs one of the most standard ways possible.
When I was talking about the commandline parameter it was referred to another program which draws a sort of overlay for a game. It wasn't OBS but I think the issue is the same. I looked at the microsoft doc about ShellExecute and from what I read it should open that absolutely normally... I will try to debug this thing, maybe I can find something and report it, as for example it is affecting other apps such as Discord (which has a service that can't be reached by a VSCode plugin when I open it via Rainmeter).

For now, thanks for your advice

Have a nice day,
Edo
oZone
Posts: 133
Joined: May 14th, 2018, 4:46 pm

Re: Launching programs behaviour

Post by oZone »

Brian wrote:
May 5th, 2020, 7:03 pm
This is somewhat misleading. RunCommand does this, but regular actions do not (unless a folder is being opened). Here is where an action "runs" a command (like an .exe, opening a folder, or opening some file).
https://github.com/rainmeter/rainmeter/blob/master/Library/CommandHandler.cpp#L496-L516

ShellExecuteEx states the following for the parameter hwnd:


What this is saying is, if you use a window handle (hwnd), then the launched program/file/folder/etc. will be ran as a child process. If you use NULL, it is not ran as a child process. So, LeftMouseUpAction=["C:\someprogram.exe"] is not launched as a child process.
I see, I am using Process Explorer so I've though that Rainmeter is creating child process.
User avatar
Brian
Developer
Posts: 2044
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Launching programs behaviour

Post by Brian »

oZone wrote:
May 5th, 2020, 8:56 pm
I see, I am using Process Explorer so I've though that Rainmeter is creating child process.
Very interesting. I wonder if the "tree hierarchy" is more of a "who spawned who" type of visual display. Even in the properties window, it does show that Rainmeter is the "parent".

So, either the meaning of "parent" in ProcessExplorer means something like "who spawned me", or the docs for ShellExecuteEx is incorrect. I can not find any information at all that suggests ShellExecuteEx always runs commands as child processes (with or without a window handle). Almost every program launched from different parts of the "shell" (like the start menu, or from a folder or shortcut) show up as an entry under the "explorer.exe" entry. I really don't think that means all of those entries are the "children" of explorer.exe.

Either way, I don't think this has any bearing on the criteria with what OBS is looking for.

-Brian
edo2313
Posts: 4
Joined: May 4th, 2020, 11:05 pm

Re: Launching programs behaviour

Post by edo2313 »

I have some news!
After trying various combinations (run from rainmeter, normally, as admin etc.) I found out that the problem is that rainmeter runs as admin and so spawns every process as admin. If I run OBS as admin or from rainmeter then, it can capture games, but if I run from the start menu it can't (obviously). I don't know if it is normal that ShellExecute executes them as admin, but for now I think my solution will be to run rainmeter NOT as admin.

Just reporting what I found, hoping it will be useful.
Bye!
User avatar
Yincognito
Posts: 2195
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Launching programs behaviour

Post by Yincognito »

According to the OP's last post, it appears the matter is solved, but just for information (if you don't know that already):

1. Rainmeter is detected as the caller / parent / whatever for another process (I used a random adware featured program here to demonstrate this). For example, this code:

Code: Select all

LeftMouseUpAction=["e:\ccc\ccc.exe"]
triggered this from my security solution (you might say they have unorthodox ways of finding out this, but the point is that it can be done):
AV Parent Detection.jpg
2. Rainmeter is detected as a 3D application in software like RivaTuner Statistics Server, so it has to be excluded in order to prevent RTSS' "skin" showing its info for a desktop application like Rainmeter (given the related job of OBS and MSI AB / RTSS, this might be relevant, if not here, maybe in other situations):
RTSS 3D.jpg
I don't know if this helps anyone, now that the matter appears to be solved, but just clarifying some things that might or might not be relevant to this or to other possible related situations in the future.

P.S. And yes, I've experienced some interesting behavior in the past as well, related to running Rainmeter as an administrator. I can't remember now what it was, but it causes some things to behave differently, that's for sure. Not that it's a bad thing and such, it's just the way it is.
You do not have the required permissions to view the files attached to this post.