notify auto wood unsupported with bilibili

This commit is contained in:
ema
2023-11-26 05:56:33 +08:00
parent e06e7c878c
commit e2f37cae39
3 changed files with 88 additions and 7 deletions

View File

@@ -312,9 +312,4 @@
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Assets\Model\" />
<Folder Include="Genshin\" />
</ItemGroup>
</Project>

View File

@@ -24,11 +24,14 @@ public class AutoWoodTask
private readonly ClickOffset _clickOffset;
private readonly Login3rdParty _login3rdParty;
public AutoWoodTask()
{
var captureArea = TaskContext.Instance().SystemInfo.CaptureAreaRect;
var assetScale = TaskContext.Instance().SystemInfo.AssetScale;
_clickOffset = new ClickOffset(captureArea.X, captureArea.Y, assetScale);
_login3rdParty = new();
}
public void Start(WoodTaskParam taskParam)
@@ -45,6 +48,12 @@ public class AutoWoodTask
break;
}
_login3rdParty.RefreshAvailabled();
if (_login3rdParty.Type == Login3rdParty.The3rdPartyType.Bilibili)
{
// TODO
throw new NormalEndException("暂未支持B服伐木后续将会增加支持");
}
Felling(taskParam);
VisionContext.Instance().DrawContent.ClearAll();
Sleep(500, taskParam.Cts);
@@ -80,7 +89,6 @@ public class AutoWoodTask
EnterGame(taskParam);
}
private void PressZ(WoodTaskParam taskParam)
{
if (_first)
@@ -164,4 +172,4 @@ public class AutoWoodTask
}
}, TimeSpan.FromSeconds(1), 50);
}
}
}

View File

@@ -0,0 +1,78 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using Vanara.PInvoke;
namespace BetterGenshinImpact.GameTask.AutoWood.Utils;
internal sealed class Login3rdParty
{
public enum The3rdPartyType
{
None,
Bilibili,
}
public bool IsAvailabled => Type != The3rdPartyType.None;
public The3rdPartyType Type { get; private set; } = default;
public void RefreshAvailabled()
{
Type = The3rdPartyType.None;
try
{
if (Process.GetProcessesByName("YuanShen").FirstOrDefault() is Process p)
{
uint tid = User32.GetWindowThreadProcessId(p.MainWindowHandle, out uint pid);
if (tid != 0)
{
using Kernel32.SafeHPROCESS hProcess = Kernel32.OpenProcess(new ACCESS_MASK(Kernel32.ProcessAccess.PROCESS_QUERY_INFORMATION), false, pid);
if (!hProcess.IsInvalid)
{
StringBuilder devicePath = new(260);
uint size = (uint)devicePath.Capacity;
if (Kernel32.QueryFullProcessImageName(hProcess, 0, devicePath, ref size))
{
FileInfo fileInfo = new(devicePath.ToString());
if (fileInfo.Exists)
{
string? configIni = Path.Combine(fileInfo.DirectoryName!, "config.ini");
string[] lines = File.ReadAllLines(configIni);
foreach (string line in lines)
{
string kv = line.Trim();
if (kv.StartsWith("cps=") && kv.EndsWith("bilibili"))
{
Type = The3rdPartyType.Bilibili;
break;
}
}
}
}
else
{
Debug.WriteLine($"Error getting process image file name. Error code: {Marshal.GetLastWin32Error()}");
}
}
}
}
}
catch
{
///
}
}
public void Login()
{
// TODO
}
}