-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Battle.net Client beta breaks capability to launch alternate versions of games #37
Comments
The --exec parameter no longer launches the game. |
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 |
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. |
So had some time this long weekend and made an experimental fix for those brave enough to try it |
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. 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);
}
} |
@SilverSaw has done some testing in #56 (comment) which shows the flaws of current implementation. Issues to resolve
I'm opening the project to Pull request targeted at fixing this issue. |
The latest beta of the Battle.net client breaks both methods bnetlauncher was using to start blizzard games:
The--exec
parameter no longer launches the game.Not being able to use Enter key breaks the launch of ptr and WoW Classic versions of the game.
The text was updated successfully, but these errors were encountered: