adirh3 / Sonar.AutoSwitch

53 stars 6 forks source link

Some games are not recognized #2

Open JohnnyDeeee opened 1 year ago

JohnnyDeeee commented 1 year ago

When running Call of Duty: Modern warfare 2 the app doesn't recognize it and won't update the Sonar config. I think this has to do with Win32WindowEventManager, i debugged the app and never got in https://github.com/adirh3/Sonar.AutoSwitch/blob/master/Sonar.AutoSwitch/Services/Win32/Win32WindowEventManager.cs#L67

I tried

_windowEventHook = SetWinEventHook(
                1, // eventMin
                2147483647, // eventMax
                IntPtr.Zero, // hmodWinEventProc
                _lpfnWinEventProc, // lpfnWinEventProc
                0, // idProcess
                0, // idThread
                WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS);

thinking this would show me all the events, but it never triggered on cod.exe.

In my procexp64 program i also cannot get any information on the process.. Could it be that this is somehow "protected" and need admin privileges to access this process? (running procexp64 with admin privileges doesn't work, so not sure if this will work in the app..) image

adirh3 commented 1 year ago

Try running the AutoSwitch as administrator and see if it works

JohnnyDeeee commented 1 year ago

Doesn't seem to work when running as admin..

thywolf commented 1 year ago

Looks like some games are protected enough to make the Win32WindowEventManager fail when switching to such a game. I'm testing a fallback for such cases - if an exception is raised when switching to such a game, making the original detection impossible, I'm just checking if the process with a given name is running. Not ideal (don't open two problematic games at the same time!), but seems to be working for Valorant :-)

JohnnyDeeee commented 1 year ago

Not ideal (don't open two problematic games at the same time!)

You could go through the whole list to check if you are running multiple games which both have profiles in the app. When you detect multiple you can show a warning to the user that he must choose which configuration will be the active one (because you can only have 1 active configuration).

But tbh, this is an edge case because i don't think people are going to run multiple games and expect this app to work in that case..

adirh3 commented 1 year ago

@JohnnyDeeee @thywolf added support for matching by title, it should help with these games. Check out 28.2.0 release and let me know if it works for you.

thywolf commented 1 year ago

Switching now works like a charm for me, @adirh3 ! Thanks a million!

FowD8 commented 1 year ago

was this figured out? I haven't been able to get it to work with Valorant...

image

FowD8 commented 1 year ago

Just a note to the above, I guess if you're using Window Title it uses a wildcard essentially. so if the window is called "VALORANT", you can just put VAL for the Window title, BUT make sure you keep Game executable name empty, I think if it has something in there, it's looking for both, and if it's a protected exe, it won't work

adirh3 commented 1 year ago

Just a note to the above, I guess if you're using Window Title it uses a wildcard essentially. so if the window is called "VALORANT", you can just put VAL for the Window title, BUT make sure you keep Game executable name empty, I think if it has something in there, it's looking for both, and if it's a protected exe, it won't work

Keep EXE name empty and title Valorant worked for me.