Skip to content

Mouse clicks misaligned when game is on secondary monitor #33

@primetime43

Description

@primetime43

Description

The bot does not work correctly when Toontown Rewritten is running on a secondary monitor. Mouse clicks land in the
wrong positions because the coordinate normalization uses primary screen dimensions regardless of which monitor the
game window is on.

Root Cause

In CoreFunctionality.cs lines 493-494, the GetNormalizedMouseCoordinates() method hardcodes
Screen.PrimaryScreen.Bounds:

int screenWidth = Screen.PrimaryScreen.Bounds.Width;
int screenHeight = Screen.PrimaryScreen.Bounds.Height;

This causes incorrect coordinate calculation when the game is on any monitor other than the primary.

Additionally, ForceGameWindowFullscreen() (lines 155-186) positions the window at (0,0), assuming the primary monitor.

Expected Behavior

The bot should detect which monitor the game window is on and use that monitor's bounds for coordinate normalization.

Suggested Fix

Replace Screen.PrimaryScreen with Screen.FromHandle() or Screen.FromPoint() to dynamically determine the correct
screen:

var windowRect = GetGameWindowRect();
var screen = Screen.FromRectangle(windowRect);
int screenWidth = screen.Bounds.Width;
int screenHeight = screen.Bounds.Height;

Workaround

Run Toontown Rewritten on the primary monitor.

Affected Files

- ToonTown Rewritten Bot/Services/CoreFunctionality.cs

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions