Compare commits

...

1 Commits

Author SHA1 Message Date
qhy040404
09a2d930be minor fix 2024-02-29 14:14:23 +08:00
2 changed files with 32 additions and 31 deletions

View File

@@ -41,39 +41,33 @@ internal sealed partial class DiscordService : IDiscordService, IDisposable
private bool IsSupported() private bool IsSupported()
{ {
try // Actually requires a discord client to be running on Windows platform.
{ // If not, discord core creation code will throw.
// Actually requires a discord client to be running on Windows platform. Process[] discordProcesses = Process.GetProcessesByName("Discord");
// If not, discord core creation code will throw.
Process[] discordProcesses = Process.GetProcessesByName("Discord");
if (discordProcesses.Length <= 0) if (discordProcesses.Length <= 0)
{
return false;
}
foreach (Process process in discordProcesses)
{
try
{ {
_ = process.Handle;
}
catch (Exception)
{
if (!isInitialized)
{
isInitialized = true;
infoBarService.Warning(SH.ServiceDiscordActivityElevationRequiredHint);
}
return false; return false;
} }
foreach (Process process in discordProcesses)
{
try
{
_ = process.Handle;
}
catch (Exception)
{
if (!isInitialized)
{
infoBarService.Warning(SH.ServiceDiscordActivityElevationRequiredHint);
}
return false;
}
}
return true;
}
finally
{
isInitialized = true;
} }
return true;
} }
} }

View File

@@ -23,8 +23,15 @@ internal sealed class LaunchExecutionBetterGenshinImpactAutomationHandlder : ILa
Uri betterGenshinImpactUri = "bettergi://start".ToUri(); Uri betterGenshinImpactUri = "bettergi://start".ToUri();
if (await Launcher.QueryUriSupportAsync(betterGenshinImpactUri, LaunchQuerySupportType.Uri) is LaunchQuerySupportStatus.Available) if (await Launcher.QueryUriSupportAsync(betterGenshinImpactUri, LaunchQuerySupportType.Uri) is LaunchQuerySupportStatus.Available)
{ {
context.Logger.LogInformation("Waiting game window to be ready"); try
context.Process.WaitForInputIdle(); {
context.Logger.LogInformation("Waiting game window to be ready");
context.Process.WaitForInputIdle();
}
catch (InvalidOperationException)
{
return;
}
context.Logger.LogInformation("Launching BetterGI"); context.Logger.LogInformation("Launching BetterGI");
await Launcher.LaunchUriAsync(betterGenshinImpactUri); await Launcher.LaunchUriAsync(betterGenshinImpactUri);