diff --git a/ScreenAssistant.ScreenInfoRecognition/Recognizers/ApexLegends/ApLegWeaponTypeScreenRecognizer.cs b/ScreenAssistant.ScreenInfoRecognition/Recognizers/ApexLegends/ApLegWeaponTypeScreenRecognizer.cs
index fdb160a..b5f9842 100644
--- a/ScreenAssistant.ScreenInfoRecognition/Recognizers/ApexLegends/ApLegWeaponTypeScreenRecognizer.cs
+++ b/ScreenAssistant.ScreenInfoRecognition/Recognizers/ApexLegends/ApLegWeaponTypeScreenRecognizer.cs
@@ -77,6 +77,7 @@ private static DirectBitmap GetAdjustedDirectBitmapOfImage(Image img, float brig
public string TestWeapons()
{
+ this._logger?.NewSnapshot();
var w1Img = GetWeapon1Image(FullScreenMode);
var w2Img = GetWeapon2Image(FullScreenMode);
w1Img.SaveTestImage();
diff --git a/ScreenAssistant.ScreenInfoRecognition/ScreenCapture.cs b/ScreenAssistant.ScreenInfoRecognition/ScreenCapture.cs
index 84c04b8..9dbd584 100644
--- a/ScreenAssistant.ScreenInfoRecognition/ScreenCapture.cs
+++ b/ScreenAssistant.ScreenInfoRecognition/ScreenCapture.cs
@@ -1,6 +1,7 @@
using System;
using System.Drawing;
using System.Drawing.Imaging;
+using System.IO;
using System.Runtime.InteropServices;
namespace TiqSoft.ScreenAssistant.ScreenInfoRecognition
@@ -30,6 +31,7 @@ public static Image CaptureScreenRelatively(float startX, float endX, float star
if (fullScreen)
{
return CaptureWindow(User32.GetDesktopWindow(), startX, endX, startY, endY);
+ //return CaptureWindowFromGraphics(User32.GetForegroundWindow(), startX, endX, startY, endY);
}
return CaptureWindow(User32.GetForegroundWindow(), startX, endX, startY, endY);
@@ -62,7 +64,7 @@ internal static Image CaptureWindow(IntPtr handle, float startX, float endX, flo
IntPtr hOld = GDI32.SelectObject(hdcDest, hBitmap);
// bitblt over
GDI32.BitBlt(hdcDest, 0, 0, (int)((endX - startX) * width / 100), (int)((endY - startY) * height / 100),
- hdcSrc, (int)(startX * width / 100), (int)(startY * height / 100), GDI32.SRCCOPY);
+ hdcSrc, (int)(startX * width / 100), (int)(startY * height / 100), GDI32.SRCCOPY | GDI32.CAPTUREBLT);
// restore selection
GDI32.SelectObject(hdcDest, hOld);
// clean up
@@ -74,6 +76,41 @@ internal static Image CaptureWindow(IntPtr handle, float startX, float endX, flo
GDI32.DeleteObject(hBitmap);
return img;
}
+
+ ///
+ /// Creates an Image object containing a screen shot of a specific window
+ ///
+ /// The handle to the window.
+ /// 0-100 percent of start by X
+ /// 0-100 percent of end by X
+ /// 0-100 percent of start by Y
+ /// 0-100 percent of end by Y
+ ///
+ internal static Image CaptureWindowFromGraphics(IntPtr handlePtr, float startX, float endX, float startY, float endY)
+ {
+ User32.RECT windowRect = new User32.RECT();
+ User32.GetWindowRect(handlePtr, ref windowRect);
+ int width = windowRect.right - windowRect.left;
+ int height = windowRect.bottom - windowRect.top;
+ var tWidth = (int) ((endX - startX) * width / 100);
+ var tHeight = (int) ((endY - startY) * height / 100);
+ var xSrc = (int) (startX * width / 100);
+ var ySrc = (int) (startY * height / 100);
+
+ if (tWidth > 0 && tHeight > 0)
+ {
+ Bitmap bitmap = new Bitmap(tWidth, tHeight);
+ using (Graphics g = Graphics.FromImage(bitmap))
+ {
+ g.CopyFromScreen(new Point(xSrc, ySrc), Point.Empty, new Size(tWidth, tHeight));
+ }
+ return bitmap;
+ }
+
+ return new Bitmap(1, 1);
+ }
+
+
///
/// Captures a screen shot of a specific window, and saves it to a file
///
@@ -101,6 +138,7 @@ public static void CaptureScreenToFile(string filename, ImageFormat format)
///
private class GDI32
{
+ public const int CAPTUREBLT = 0x40000000;
public const int SRCCOPY = 0x00CC0020; // BitBlt dwRop parameter
[DllImport("gdi32.dll")]
diff --git a/ScreenAssistant/Games/ApLeg/WeaponAL.cs b/ScreenAssistant/Games/ApLeg/WeaponAL.cs
index 5f529ff..6d1aa04 100644
--- a/ScreenAssistant/Games/ApLeg/WeaponAL.cs
+++ b/ScreenAssistant/Games/ApLeg/WeaponAL.cs
@@ -13,7 +13,7 @@ public enum WeaponAL
{
[WeaponData("", 0, " ")]
Unknown = 1 << 0,
- [WeaponData("Havoc", 5, "HAVUC")]
+ [WeaponData("Havoc", 4, "HAVUC")]
Havoc = 1 << 1,
[WeaponData("Triple take", 4)]
TripleTake = 1 << 2,
diff --git a/ScreenAssistant/Games/ApLeg/Weapons/Havoc.cs b/ScreenAssistant/Games/ApLeg/Weapons/Havoc.cs
index 81d7b0d..a4f1f71 100644
--- a/ScreenAssistant/Games/ApLeg/Weapons/Havoc.cs
+++ b/ScreenAssistant/Games/ApLeg/Weapons/Havoc.cs
@@ -11,7 +11,7 @@ public Havoc(string name, double burstSeconds, string recognizedName, int numOfM
public override double AdjustMouse(int shotNumber)
{
- var notOffsettingDelay = this.GetModuleType(4) == WeaponModuleType.Legendary ? 0 : 6;
+ var notOffsettingDelay = this.GetModuleType(3) == WeaponModuleType.Legendary ? 0 : 6;
if (shotNumber > notOffsettingDelay)
{
this.AdjustmentCoefficient = CalculateAdjustment(shotNumber, 40);