Example #1
0
 /// <summary>
 /// Capture image using WinAPI
 /// </summary>
 /// <param name="hWnd"></param>
 /// <param name="cropstart"></param>
 /// <param name="cropend"></param>
 /// <param name="lineNumber"></param>
 /// <param name="caller"></param>
 /// <returns></returns>
 public static ScreenshotData ImageCapture(IntPtr hWnd, Point cropstart, Point cropend, [CallerLineNumber] int lineNumber = 0, [CallerMemberName] string caller = null)
 {
     try
     {
         Stopwatch s  = Stopwatch.StartNew();
         Rectangle rc = new Rectangle();
         DllImport.GetWindowRect(hWnd, ref rc);
         Bitmap   bmp       = new Bitmap(rc.Width, rc.Height, PixelFormat.Format32bppArgb);
         Graphics gfxBmp    = Graphics.FromImage(bmp);
         IntPtr   hdcBitmap = gfxBmp.GetHdc();
         DllImport.PrintWindow(hWnd, hdcBitmap, 0);
         gfxBmp.ReleaseHdc(hdcBitmap);
         gfxBmp.Dispose();
         Variables.AdvanceLog("Screenshot saved to memory used " + s.ElapsedMilliseconds + " ms", lineNumber, caller);
         s.Stop();
         bmp = CropImage(bmp, cropstart, cropend, lineNumber, caller);
         if (Variables.ImageDebug)
         {
             bmp.Save("Profiles\\Logs\\" + Encryption.SHA256(DateTime.Now.ToString()) + ".bmp");
         }
         return(Compress(bmp));
     }
     catch
     {
         Instance.captureerror = true;
         return(ImageCapture());
     }
 }
Example #2
0
        /// <summary>
        /// Capture loop
        /// </summary>

        private void Capt()
        {
            do
            {
                Thread.Sleep(1000);
                if (Variables.Proc != null)
                {
                    if (Variables.Proc.HasExited)
                    {
                        Variables.Proc = null;
                        Docked         = false;
                        continue;
                    }
                    if (Variables.emulator.EmulatorName() == "Nox")
                    {
                        var hide = DllImport.GetAllChildrenWindowHandles(IntPtr.Zero, "Qt5QWindowToolSaveBits", "Form", 2);
                        foreach (var h in hide)
                        {
                            DllImport.ShowWindow(h, 0);
                        }
                    }
                    try
                    {
                        var       handle = Variables.Proc.MainWindowHandle;
                        var       parent = DllImport.GetParent(handle);
                        Rectangle rect   = new Rectangle();
                        DllImport.GetWindowRect(handle, ref rect);
                        if (!Docked)
                        {
                            if (!ScriptRun.Run)
                            {
                                return;
                            }
                            PrivateVariable.EmuDefaultLocation = rect;
                            panel3.Invoke((MethodInvoker) delegate
                            {
                                DllImport.SetParent(Variables.Proc.MainWindowHandle, panel3.Handle);
                            });
                            tp.Invoke((MethodInvoker) delegate { tp.BringToFront(); });
                            Docked = true;
                        }
                        if (rect.X != -1 || rect.Y != -30)
                        {
                            DllImport.MoveWindow(handle, -1, -30, 1318, 752, false);
                        }
                    }
                    catch
                    {
                    }
                }
                else
                {
                    Docked = false;
                }
            } while (ScriptRun.Run);
        }
Example #3
0
        /// <summary>
        /// Capture loop
        /// </summary>

        private void Capt()
        {
            bool Docked = false;

            do
            {
                Thread.Sleep(2000);
                if (Variables.Proc != null)
                {
                    if (Variables.Proc.HasExited)
                    {
                        Variables.Proc = null;
                        Docked         = false;
                        continue;
                    }
                    try
                    {
                        var       handle = Variables.Proc.MainWindowHandle;
                        Rectangle rect   = new Rectangle();
                        DllImport.GetWindowRect(handle, ref rect);
                        if (!Docked)
                        {
                            if (!ScriptRun.Run)
                            {
                                return;
                            }
                            PrivateVariable.Instance.EmuDefaultLocation = rect;
                            panel3.Invoke((MethodInvoker) delegate
                            {
                                DllImport.SetParent(Variables.Proc.MainWindowHandle, panel3.Handle);
                            });
                            tp.Invoke((MethodInvoker) delegate { tp.BringToFront(); });
                            panel3.Invoke((MethodInvoker) delegate
                            {
                                DllImport.SetParent(Variables.Proc.MainWindowHandle, panel3.Handle);
                            });
                            Docked = true;
                        }
                        if (rect.X != -1 || rect.Y != -30)
                        {
                            DllImport.MoveWindow(handle, -1, -30, 1318, 752, false);
                        }
                    }
                    catch
                    {
                    }
                }
                else
                {
                    Docked = false;
                }
            } while (ScriptRun.Run);
        }