Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to open Windows Store Apps #238

Open
dewijones94 opened this issue Jun 27, 2023 · 12 comments
Open

Ability to open Windows Store Apps #238

dewijones94 opened this issue Jun 27, 2023 · 12 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@dewijones94
Copy link

While trying to create shortcuts to Xbox App Games i get an access denied launching the actual exe, this is because of the way permissions are handled by Xbox and there is no way to alter the permissions of the exe. The actual app that i am trying to create a shortcut to is Forza Horizon 5.

I'd assume that having the ability to choose an app installed on the device as the shortcut, rather than just an exe or com library would negate this message, bypassing the need to use the exe.

@dewijones94 dewijones94 added the enhancement New feature or request label Jun 27, 2023
@terrymacdonald terrymacdonald added this to the 3.0.0 milestone Jun 27, 2023
@terrymacdonald
Copy link
Owner

@dewijones94 The issue here is that all Xbox App Games I've seen are actually Microsoft Store Games, and those have a completely different way of running. They use the new UWP or Windows App way of operating, which doesn't really work easily with .net Framework-based software like DisplayMagician. I've already had a person request some support for UWP games under #98, but it's really not very simple to add.

I've already added the ability to start a UWP app (but not monitor it for closure), but that is under the Application section, not the game one. To use it, create an Application shortcut rather than a Game shortcut. You should be able to select Forza Horizon 5 from the list of Applications, and it will still work ok - though please note that DisplayMagician is unlikely to be able to detect that the game has started so it will likely just finish the game shortcut and revert everything back straight away. Unfortunately this is a windows permission thing, and the only way I can get around that is to completely rewrite DisplayMagician from scratch as a new WinUI3 Windows App.

I've actually started doing just that, but it will take 6 month to a year to port everything over as it is such a massive change in the background. The WinUI version will be called DisplayMagician v3, and will be able to run/monitor UWP and Windows App games just as well as traditional apps.

Hope that clarifies?

Thanks
Terry

@dev1981
Copy link

dev1981 commented Jun 28, 2023

hi,

maybe it will help to use the cmdline mentioned in that article; (bottom)
https://answers.microsoft.com/en-us/windows/forum/all/starting-windows-10-store-app-from-the-command/836354c5-b5af-4d6c-b414-80e40ed14675

AND / OR a dedicated powershell script which u can reference in DPM.
Then the cmdline in DPM will point to powershell.exe + script-cmdline
as well starting the game process and have a wait for the started Application might be possible. But yes, it will be a workarround.

@dewijones94
Copy link
Author

Thanks both. Completely understand it’s not a quick think @terrymacdonald, just wanted to put it forward for consideration. I’m happy to work round it for now, honestly loving the app so far! And also happy to help beta test anything for you 😉

@dev1981 using the shell command works to launch it, unfortunately using the exe to detect when it’s closed doesn’t work either, so I’ve built a loop in the script to monitor for the exe and close when it ends so it can use that to switch back the display, so definitely a workaround for now as well!

@terrymacdonald
Copy link
Owner

terrymacdonald commented Jun 29, 2023 via email

@dewijones94
Copy link
Author

Hi @terrymacdonald certainly, I can send over first thing with some instruction to customise it for other apps as well. 7:45pm here and I’m not sat at my computer right now!

@dewijones94
Copy link
Author

Hi @terrymacdonald

Here is the batch i am using, just a very simple launch and wait essentially. The App launch shortcut is done using the link above that Dev1981 shared also https://answers.microsoft.com/en-us/windows/forum/all/starting-windows-10-store-app-from-the-command/836354c5-b5af-4d6c-b414-80e40ed14675
To note, when looking at the target in the shortcut to find the app name, there is a section that has the exclamation and then the app name, if this is present it already contains everything you need to launch the app without having to go to the XML as the person in the link mentions. And to also note, if this is for a game using the Xbox app, the location of that XML will be in the location that you install the game to.

In my example below, i use a loopback ping to wait because the pre-wrapper takes ages to launch the actual executable (forza things) but i would recommend leaving it in and reducing it based on the time it takes for their app to launch. Then i am just using tasklist to search for the exe and loop if its still running every 5 seconds. Also, to note, tasklist results are case sensitive, so for example, my "ForzaHorizon5" would not be detected if it was in lower case.

explorer.exe shell:appsFolder\Microsoft.624F8B84B80_8wekyb3d8bbwe!Forzahorizon5

ping 127.0.0.1 -n 21 > nul

:LOOP
Tasklist | find "ForzaHorizon5" >nul
IF ERRORLEVEL 1 (
  GOTO CONTINUE
) ELSE (
  ECHO Forza is still running
  ping 127.0.0.1 -n 6 > nul
  GOTO LOOP
)

:CONTINUE
Exit

On a complete side note, when game shortcuts are created in your application, are they stored somewhere? I am getting an unhandled exception when loading the shortcuts screen, displaying the shortcuts, and i think its because it might be referencing an icon no longer there? So justy wanted to try manually deleting them and seeing if it'll load then. If the icon is the issue, might be worth opening another issue to add a default icon if one is not found to catch the exception?

@dewijones94
Copy link
Author

Hi @terrymacdonald

Further on the above regarding the unhandled exception, i have found the cause. I managed to find the JSON file that the shortcuts are listed in and removed the one i created pointing to the batch file. This then stopped displaying the unhandled exception. To be sure it was that i recreated the shortcut and as soon as i click save, the unhandled exception comes up. If i click continue, the area where the shortcuts displayed just displays a red cross over it.

I'm guessing this is because im referencing a bat file and its unable to scrap the icon for this? I've pasted the exception text for you below. Would it be best to have a fallback on this scrape, where the launching file is not an exe, and falls back to a default DisplayMagician Icon?

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at DisplayMagician.UIForms.ShortcutILVRenderer.DrawItem(Graphics g, ImageListViewItem item, ItemState state, Rectangle bounds)
at Manina.Windows.Forms.ImageListView.ImageListViewRenderer.RenderItems(Graphics g)
at Manina.Windows.Forms.ImageListView.ImageListViewRenderer.Render(Graphics graphics)
at Manina.Windows.Forms.ImageListView.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

@terrymacdonald
Copy link
Owner

terrymacdonald commented Jun 30, 2023 via email

@dewijones94
Copy link
Author

Thanks, so wouldn't really be able to use that as a workaround until thats handled, as it would break the shortcuts menu for users.

@terrymacdonald
Copy link
Owner

@dewijones94 Are you able to test your batch file with this new test version of DisplayMagician I've made?

The latest test version should be working properly, and hopefully fixes your issue. Could you please test it for me so I know that it fixes your issue? If it does then I'll be able to close this issue as the fix will be part of the next full release.

DisplayMagicianSetup-V2.6.0.515-No-NvApi_SetDisplayConfig.zip

Thanks!

@terrymacdonald
Copy link
Owner

@dewijones94 I've been testing opening UWP apps and monitoring them from DisplayMagician, and I think the most recent code changes may have managed to get this working.

DisplayMagicianSetup-v2.6.0.521-uwp.zip

Can you please install this test version and see that you can open Windows Store apps and DisplayMagician will wait for them to close?

Thanks
Terry

@terrymacdonald terrymacdonald modified the milestones: 3.0.0, 2.6.0 Feb 10, 2024
@terrymacdonald
Copy link
Owner

Oops I broke the setup with my previous version. This version has a corrected setup that should install everything properly.

DisplayMagicianSetup-v2.6.0.522-corrected-setup.zip

Thanks
Terry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants