Skip to content

Commit 5cb0ecb

Browse files
committed
Fixed pos error when fetching exit button under high DPI
1 parent c010784 commit 5cb0ecb

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

build/nsis/setup.nsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
!define PRODUCT_NAME "GenshinWoodmen"
2-
!define PRODUCT_VERSION "1.3.0.0"
2+
!define PRODUCT_VERSION "1.3.1.0"
33
!define PRODUCT_PUBLISHER "ema"
44
!define PRODUCT_WEB_SITE "https://github.com/emako"
55
!define PRODUCT_LEGAL "Licensed under MIT"

src/GenshinWoodmen/Core/LaunchCtrl.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Text;
55
using System.Threading;
66
using System.Threading.Tasks;
7-
using System.Windows.Forms;
87

98
namespace GenshinWoodmen.Core
109
{
@@ -88,21 +87,24 @@ public static async Task<bool> Logout()
8887
UserSimulator.Input.Keyboard.KeyPress(VirtualKeyCode.ESCAPE);
8988
await JiggingProcessor.Delay(950);
9089
RECT rect = NativeMethods.GetWindowRECT(hwnd);
91-
NativeMethods.SetCursorPos(rect.Left + 20, rect.Bottom - SystemInformation.CaptionHeight - 10);
90+
NativeMethods.SetCursorPos(rect.Left + 20, rect.Bottom - 30);
9291
await JiggingProcessor.Delay(100);
93-
UserSimulator.Input.Mouse.LeftButtonClick(); // ExitButton
92+
UserSimulator.Input.Mouse.LeftButtonClick(); // Exit
9493
await JiggingProcessor.Delay(800);
9594
(double cx, double cy) = ((rect.Right - rect.Left) / 2d, (rect.Bottom - rect.Top) / 2d);
9695
double ratio = (rect.Right - rect.Left) / (double)(rect.Bottom - rect.Top);
9796
(double xfactor, double yfactor) = (1.1d, new Func<double>(() =>
9897
{
98+
// Inspected from ratio (such as 1.33, 1.5, 1.6, 1.78), calced without `SystemInformation.CaptionHeight` actually.
99+
// TODO: Calc with `SystemInformation.CaptionHeight`.
99100
if (ratio >= 1.6d) return 1.4d;
100101
else if (ratio >= 1.5d) return 1.35d;
102+
else if (ratio >= 1.4d) return 1.33d;
101103
else return 1.3d;
102104
}).Invoke());
103105
NativeMethods.SetCursorPos(rect.Left + (int)(cx * xfactor), rect.Top + (int)(cy * yfactor));
104106
await JiggingProcessor.Delay(100);
105-
UserSimulator.Input.Mouse.LeftButtonClick(); // OKButton
107+
UserSimulator.Input.Mouse.LeftButtonClick(); // OK
106108
});
107109
}
108110

src/GenshinWoodmen/GenshinWoodmen.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
<Platforms>x64</Platforms>
1212
<AssemblyName>genshin-woodmen</AssemblyName>
1313
<UseWindowsForms>True</UseWindowsForms>
14-
<AssemblyVersion>1.3.0</AssemblyVersion>
15-
<FileVersion>1.3.0</FileVersion>
16-
<Version>$(VersionPrefix)1.3.0</Version>
14+
<AssemblyVersion>1.3.1</AssemblyVersion>
15+
<FileVersion>1.3.1</FileVersion>
16+
<Version>$(VersionPrefix)1.3.1</Version>
1717
<Authors>ema</Authors>
1818
<Company>Lemutec</Company>
1919
<RestoreSources>$(RestoreSources);..\packages\vccli.net\;https://api.nuget.org/v3/index.json</RestoreSources>

src/GenshinWoodmenSetup/Package.appxmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Identity
1010
Name="c17bc862-e10e-4618-b717-e47dd2bf65c8"
1111
Publisher="CN=ema"
12-
Version="1.3.0.0" />
12+
Version="1.3.1.0" />
1313

1414
<Properties>
1515
<DisplayName>GenshinWoodmen</DisplayName>

0 commit comments

Comments
 (0)