Many improvements on detecting apps

Detecting better which name is the real name of the app.
Detecting if a installed appx is framework properly and excluding it
from the list.
Detecting appx bundles and properly listing individual entries.
Detecting icons to use
UWPTest
Brian Lima 8 years ago
parent 760bdee879
commit 145a77d766

@ -5,9 +5,9 @@ VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UWPHook", "UWPHook\UWPHook.csproj", "{AFE09BCF-28A4-48EE-876B-FEF080D04D5F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpSteam", "..\SharpSteam\SharpSteam\SharpSteam.csproj", "{D0A686FB-B373-4FBC-A0DD-C3417276A816}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpSteam", "..\..\Visual Studio 2015\Projects\SharpSteam\SharpSteam\SharpSteam.csproj", "{D0A686FB-B373-4FBC-A0DD-C3417276A816}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VDFParser", "..\SharpSteam\VDFParser\VDFParser\VDFParser.csproj", "{9543FB59-1EB6-4638-B24C-B12B9D4A15FC}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VDFParser", "..\..\Visual Studio 2015\Projects\SharpSteam\VDFParser\VDFParser\VDFParser.csproj", "{9543FB59-1EB6-4638-B24C-B12B9D4A15FC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

@ -1,4 +1,7 @@
using System.ComponentModel;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Runtime.CompilerServices;
namespace UWPHook
@ -41,6 +44,40 @@ namespace UWPHook
set { _aumid = value; }
}
private string _icon;
public string Icon
{
get { return _icon; }
set { _icon = value; }
}
public string widestSquareIcon()
{
string result = "";
Size size = new Size(0, 0);
List<string> images = new List<string>();
//Get every file on the directory
images.AddRange( Directory.GetFiles(_icon, "*.jpg", SearchOption.AllDirectories));
images.AddRange(Directory.GetFiles(_icon, "*.png", SearchOption.AllDirectories));
//Decide which is the largest
foreach (string image in images)
{
Image i = Image.FromFile(image);
if (i.Width == i.Height && (i.Size.Height > size.Height))
{
size = i.Size;
result = image;
}
}
return result;
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)

@ -1,5 +1,6 @@
using SharpSteam;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.IO;
@ -113,7 +114,7 @@ namespace UWPHook
Exe = @"""" + System.Reflection.Assembly.GetExecutingAssembly().Location + @""" " + app.Aumid,
StartDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
AllowDesktopConfig = 1,
Icon = "",
Icon = app.widestSquareIcon(),
Index = shortcuts.Length,
IsHidden = 0,
OpenVR = 0,
@ -162,6 +163,7 @@ namespace UWPHook
private void Bwr_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
grid.IsEnabled = true;
listGames.Columns[1].IsReadOnly = true;
listGames.Columns[2].IsReadOnly = true;
progressBar.Visibility = Visibility.Collapsed;
label.Content = "Installed Apps";
@ -171,22 +173,37 @@ namespace UWPHook
{
try
{
var installedApps = AppManager.GetInstalledApps();
//Get all installed apps on the system excluding frameworks
List<String> installedApps = AppManager.GetInstalledApps();
//Alfabetic sort
installedApps.Sort();
//Split every app that we couldn't resolve the app name
var x = (from s in installedApps where s.Contains("double click") select s).ToList<String>();
//Remove them from the original list
installedApps.RemoveAll(item => item.Contains("double click"));
//Rejoin them in the original list, but putting them into last
installedApps = installedApps.Union(x).ToList<String>();
foreach (var app in installedApps)
{
//Remove end lines from the String and split both values, I split the appname and the AUMID using |
//I hope no apps have that in their name. Ever.
var valor = app.Replace("\r\n", "").Split('|');
//Frameworks by Microsoft don fill the displayname at all ot have ms-resource as a name instead, this excludes them making the list less bloated
if (!String.IsNullOrWhiteSpace(valor[0]) && !valor[0].Contains("ms-resource"))
if (!String.IsNullOrWhiteSpace(valor[0]))
{
//We get the default square tile to find where the app stores it's icons, then we resolve which one is the widest
string logosPath = Path.GetDirectoryName(valor[1]);
Application.Current.Dispatcher.BeginInvoke((Action)delegate ()
{
Apps.Entries.Add(new AppEntry() { Name = valor[0], Aumid = valor[1], Selected = false });
Apps.Entries.Add(new AppEntry() { Name = valor[0], Icon = logosPath, Aumid = valor[2], Selected = false});
});
}
}
}
catch (Exception ex)
{

@ -1,20 +1,37 @@
$installedapps = get-AppxPackage
$invalidNames = '*ms-resource*', '*DisplayName*'
$aumidList = @()
foreach ($app in $installedapps)
{
try {
foreach ($appx in (Get-AppxPackageManifest $app))
if(-not $app.IsFramework){
foreach ($id in (Get-AppxPackageManifest $app).package.applications.application.id)
{
$appx = Get-AppxPackageManifest $app;
$name = $appx.Package.Properties.DisplayName;
if($name -like '*DisplayName*' -or $name -like '*ms-resource*')
{
$name = $appx.Package.Applications.Application.VisualElements.DisplayName;
}
if($name -like '*DisplayName*' -or $name -like '*ms-resource*')
{
$name = "App name not found, double click here to edit it";
}
$logo = $app.InstallLocation + "\" + $appx.Package.Applications.Application.VisualElements.Square150x150Logo;
$aumidList += $name + "|" + $logo + "|" +
$app.packagefamilyname + "!" + $id+ ";"
}
}
}
catch
{
$aumidList += $appx.Package.Properties.DisplayName + " | "+
$app.packagefamilyname + "!" + $appx.package.applications.application.id + ";"
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
}
} catch {
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
}
}
$aumidList;

@ -157,16 +157,6 @@
<ItemGroup>
<EmbeddedResource Include="Resources\GetAUMIDScript.txt" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\SharpSteam\SharpSteam\SharpSteam.csproj">
<Project>{d0a686fb-b373-4fbc-a0dd-c3417276a816}</Project>
<Name>SharpSteam</Name>
</ProjectReference>
<ProjectReference Include="..\..\SharpSteam\VDFParser\VDFParser\VDFParser.csproj">
<Project>{9543fb59-1eb6-4638-b24c-b12b9d4a15fc}</Project>
<Name>VDFParser</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\WhiteTransparent.png" />
<Resource Include="Resources\BlackTransparent.png" />
@ -188,6 +178,16 @@
<ItemGroup>
<Resource Include="Resources\hook2.ico" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Visual Studio 2015\Projects\SharpSteam\SharpSteam\SharpSteam.csproj">
<Project>{d0a686fb-b373-4fbc-a0dd-c3417276a816}</Project>
<Name>SharpSteam</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Visual Studio 2015\Projects\SharpSteam\VDFParser\VDFParser\VDFParser.csproj">
<Project>{9543fb59-1eb6-4638-b24c-b12b9d4a15fc}</Project>
<Name>VDFParser</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

Loading…
Cancel
Save