Skip to content

[Bug]: Multiple Screen getPixelColor broken #19

@iamnobodysir

Description

@iamnobodysir

Version

0.2.2

Description of the issue

I notice when I have 2 monitors and uses getPixelColor(x, y) it will not show proper color code to me. The moment I shut down 1 of my monitor, it work accordingly. Sample code below on how I test it.

Steps to reproduce


import { getMousePos, getPixelColor, moveMouse } from '@tego/botjs';

const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));

async function main() {
    console.log("=== COORDINATE & COLOR FINDER ===");
    console.log("Move your mouse over the game items on the PRIMARY monitor.");
    console.log("Press Ctrl+C to stop.\n");

    while (true) {
        try {
            // 1. Where is the mouse?
            const pos = await getMousePos();

            // 2. What color does the bot see there?
            const color = await getPixelColor(pos.x, pos.y);


            // 3. Print it on one line (updates in place)
            process.stdout.write(`\rX: ${pos.x.toString().padEnd(5)} | Y: ${pos.y.toString().padEnd(5)} | Color: ${color.hex || '??????'}   `);

            await delay(100);
        } catch (e) {
            // Ignore errors if mouse is out of bounds momentarily
        }
    }
}

main();

Logs or error messages

Environment

No response

Checklist

  • I have searched existing issues
  • I am using the latest version

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions