private Rectangle GetBSArea()
 {
     if (!BlueStackHelper.IsBlueStackRunning)
     {
         return(Rectangle.Empty);
     }
     Win32.RECT win32rect;
     if (!Win32.GetClientRect(BlueStackHelper.GetBlueStackWindowHandle(), out win32rect))
     {
         return(Rectangle.Empty);
     }
     return(Rectangle.FromLTRB(win32rect.Left, win32rect.Top, win32rect.Right, win32rect.Bottom));
 }
Exemple #2
0
        static public void BSTest2()
        {
            IntPtr hWnd = BlueStackHelper.GetBlueStackWindowHandle();//Win32.FindWindow("Notepad", null);

            AdvancedMode = false;
            if (hWnd == IntPtr.Zero)
            {
                MessageBox.Show("You should run BlueStack first before trying this test");
            }
            else
            {
                Send(hWnd, "2> Does it work? And what for 'éàè'?");
            }
        }
 private bool OffsetToBSClientScrrenCoord(ref Rectangle rect)
 {
     if (!BlueStackHelper.IsBlueStackRunning)
     {
         return(false);
     }
     Win32.Point origin = new Win32.Point(0, 0);
     if (Win32.ClientToScreen(BlueStackHelper.GetBlueStackWindowHandle(), ref origin))
     {
         return(false);
     }
     rect.Offset(origin.x, origin.y);
     return(true);
 }
        /// <summary>
        /// This capture algorithm should behave as on the background mode of Autoit Coc Bot (as at end of january 2015)
        /// </summary>
        /// <param name="left"></param>
        /// <param name="top"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <returns></returns>
        public Bitmap SnapShot(int left, int top, int width, int height, bool backgroundMode = true)
        {
            FreeCurrentImage();
            IntPtr hWnd = BlueStackHelper.GetBlueStackWindowHandle();

            if (hWnd == IntPtr.Zero)
            {
                return(null);
            }
            IntPtr hCaptureDC = Win32.GetWindowDC(hWnd);
            IntPtr hMemDC     = Win32.CreateCompatibleDC(hCaptureDC);

            hBitmap = Win32.CreateCompatibleBitmap(hCaptureDC, width, height);
            IntPtr hObjOld = Win32.SelectObject(hMemDC, hBitmap);

            bool result = true;

            if (backgroundMode)
            {
                if (result)
                {
                    result = Win32.PrintWindow(hWnd, hMemDC, 0);
                }
                if (result)
                {
                    Win32.SelectObject(hMemDC, hBitmap);
                }
            }
            if (result)
            {
                result = Win32.BitBlt(hMemDC, 0, 0, width, height, hCaptureDC, left, top, Win32.TernaryRasterOperations.SRCCOPY);
            }
            if (result)
            {
                BitMap = Bitmap.FromHbitmap(hBitmap);
            }
            Win32.DeleteDC(hMemDC);
            Win32.SelectObject(hMemDC, hObjOld);
            Win32.ReleaseDC(hWnd, hCaptureDC);
            Win32.DeleteObject(hBitmap);
            Debug.Assert(result);
            return(BitMap);
        }
 static public string GetBlueStackExecutablePath()
 {
     return(GetExecutablePath(BlueStackHelper.GetBlueStackWindowHandle()));
 }
Exemple #6
0
 static public void SendToBS(string message)
 {
     Send(BlueStackHelper.GetBlueStackWindowHandle(), message);
 }
Exemple #7
0
 static public void SendVirtualKeyToBS(VirtualKeys vk)
 {
     SendVirtualKey(BlueStackHelper.GetBlueStackWindowHandle(), vk);
 }