获取Android设备的屏幕截图

时间:2018-06-27 16:22:25

标签: c# android appium ironpython

我尝试使用appium获取android设备的屏幕截图,因为appium没有解决方案来实时获取视频/查看应用。

我具有C#的功能以获取图像(截图)

public Image GetImages()
    {
        Image screen_shot = null;
        try
        {
            if (driverAndroid == null)
            {
                return screen_shot;
            }
            var screenshot = ((ITakesScreenshot)driverAndroid).GetScreenshot();
            var ms = new MemoryStream(screenshot.AsByteArray);
            screen_shot = Image.FromStream(ms);
            ms.Dispose();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
        }
        return screen_shot;
    }

然后我尝试使用ironpython来调用它

class HelloWorldForm(Form):

    def __init__(self):
        app = test()
        Form.__init__(self)
        pictureBox = PictureBox()
        image = app.GetImages()
        pictureBox.SizeMode = PictureBoxSizeMode.StretchImage
        pictureBox.Image = image
        pictureBox.Dock = DockStyle.Fill
        self.Controls.Add(pictureBox)
        self.Show()



Application.EnableVisualStyles()
form = HelloWorldForm()
Application.Run(form)

我现在只能得到第一张图像,我将其放在while函数中,但是它不起作用。 对代码进行任何解决方案或修改,以便我可以实时获取屏幕截图,例如视频。

0 个答案:

没有答案
相关问题