Git Product home page Git Product logo

Comments (6)

Nyi-code avatar Nyi-code commented on July 19, 2024

The --exec parameter no longer launches the game.
it does, as long as you already have battle.net.exe running...

from bnetlauncher.

dafzor avatar dafzor commented on July 19, 2024

Battle.net client 1.23 has had some usability fixes so some progress by blizzard is being made, however enter still does not default to launching the game.

Tested in 1.25.0.12296 beta

from bnetlauncher.

dafzor avatar dafzor commented on July 19, 2024

Update on the issue, beta is now released with enter key functionality still removed. So launching alternative versions of games is still broken.

A proof of concept been done on trying to find a button in a window and sending a mouse click event but it's not very elegant or robust.

That said I currently not inclined to invest the time into bnetlauncher to re-implement the feature.

from bnetlauncher.

dafzor avatar dafzor commented on July 19, 2024

So had some time this long weekend and made an experimental fix for those brave enough to try it

from bnetlauncher.

behzad62 avatar behzad62 commented on July 19, 2024

I would suggest looking for more than one pixel color match to make it more robust in the case there is a pixel with a same color somewhere else in the Battle.net client window.
The code below should be able to find the button location within the Bnet client in few milliseconds, given the bitmap of the client window.

unsafe Point? FindButtonLocation(Bitmap bitmap, Color btnColor)
            {
                int bytesPerPixel = 4;
                const int neededMatchPixelColors = 100;
                Size focusSize = new Size(10, 10);
                System.Drawing.Imaging.BitmapData mapSource = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, bitmap.PixelFormat);
                int scanStride = bitmap.Width * bytesPerPixel;
                byte* scanFirstPixel = (byte*)mapSource.Scan0;
                Point? btnLocation = null;
                for(int y = bitmap.Height / 2; y < bitmap.Height; y++)
                {
                    byte* currentLine = scanFirstPixel + (y * scanStride);
                    for (int x = 0; x < scanStride / 3; x += bytesPerPixel)
                    {
                        var currentScreenPosition = new Point(x / bytesPerPixel, y);
                        byte A = currentLine[x + 3];
                        byte R = currentLine[x + 2];
                        byte G = currentLine[x + 1];
                        byte B = currentLine[x];
                        bool mainPixelFound = A == btnColor.A && R == btnColor.R && G == btnColor.G && B == btnColor.B;
                        if (!mainPixelFound)
                            continue;
                        int checkPixelsFound = 0;
                        bool allcheckPixelsFound = checkPixelsFound == neededMatchPixelColors;
                        if (!allcheckPixelsFound)
                        {
                            var mainPixelLocation = new Point(x / bytesPerPixel, y);//relative to the scan region
                            var focusRegion = GetScanRegionAroundMainPixel(mainPixelLocation, focusSize);//relative to the scan region
                            byte* focusFirstPixel = scanFirstPixel + (focusRegion.Y * scanStride) + focusRegion.X * bytesPerPixel;
                            int focusStride = focusRegion.Width * bytesPerPixel;
                            for (int j = 0; j < focusRegion.Height; j++)
                            {
                                byte* focustLine = focusFirstPixel + (j * scanStride);
                                for (int i = 0; i < focusStride; i += bytesPerPixel)
                                {
                                    A = focustLine[i + 3];
                                    R = focustLine[i + 2];
                                    G = focustLine[i + 1];
                                    B = focustLine[i];
                                    bool checkPixelFound = A == btnColor.A && R == btnColor.R && G == btnColor.G && B == btnColor.B;
                                    if (checkPixelFound)
                                    {
                                        checkPixelsFound++;
                                        allcheckPixelsFound = checkPixelsFound == neededMatchPixelColors;
                                    }
                                    if (allcheckPixelsFound)
                                    {
                                        bitmap.UnlockBits(mapSource);
                                        btnLocation = currentScreenPosition;
                                        return btnLocation;
                                    }
                                }
                            }
                        }
                    }
                }
                bitmap.UnlockBits(mapSource);
                return btnLocation;

                Rectangle GetScanRegionAroundMainPixel(Point currentLocation, Size focusScanSize)
                {
                    Point centerPoint = new Point(currentLocation.X - focusScanSize.Width / 2, currentLocation.Y - focusScanSize.Height / 2);//adjust point to be center of rectangle
                    return new Rectangle(centerPoint, focusScanSize);
                }
            }

from bnetlauncher.

dafzor avatar dafzor commented on July 19, 2024

@SilverSaw has done some testing in #56 (comment) which shows the flaws of current implementation.

Issues to resolve

  • Unreliable method to obtain main game window
  • Single pixel match instead of "zone"

I'm opening the project to Pull request targeted at fixing this issue.

from bnetlauncher.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.