Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to take screenshots for UI element?
#7
Hi dear Gintaras,

I am sorry to bother you again, I was stumped by another UI element screenshot issue. I am extracting all the logos from a website Brand, Below is my code: 
Code:
Copy      Help
var w = wnd.find(1, "Global 500 2023 | Brand Value Ranking League Table | Brandirectory - Google Chrome", "Chrome_WidgetWin_1");

for (int i = 2; i < 20; i++) {
    var e = w.Elm["web:DOCUMENT", "Global 500 2023 | Brand Value Ranking League Table | Brandirectory", navig: $"fi3 ch5 fi3 ch{i} ch3"].Find(1);
    e.ScrollTo();
    using var bitmap = CaptureScreen.Image(e.Rect);
    var ms = new MemoryStream();
    bitmap.Save(folders.Desktop + $"logo/{e.Name.Split("/")[0]}.png");
    bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
    print.it($"<><image \"image:{Convert.ToBase64String(ms.ToArray())}\">");
    ScriptEditor.ShowMainWindow(true);
}

I just set the row number per page to "All"  to get rid of using too many for loops, that way I could use e.ScrollTo() instead of click turn page button. The problem is the screenshots which was taken are missing edge sometimes. I would like to ask your advise to get rid of this problem. Thank you so much!


[Image: Jz5zt3f]

I have sort of solved this problem by insert  var e2 and e2.ScrollTo(); .2.s();​​​​​​​ ,I would like to know if there is any efficient solution? 
Code:
Copy      Help
var w = wnd.find(1, "Global 500 2023 | Brand Value Ranking League Table | Brandirectory - Google Chrome", "Chrome_WidgetWin_1");

for (int i = 2; i < 50; i++) {
    var e = w.Elm["web:DOCUMENT", "Global 500 2023 | Brand Value Ranking League Table | Brandirectory", navig: $"fi3 ch5 fi3 ch{i} ch3"].Find(1);
    var e2 = w.Elm["web:DOCUMENT", "Global 500 2023 | Brand Value Ranking League Table | Brandirectory", navig: $"fi3 ch5 fi3 ch{i+5} ch3"].Find(1);
    e2.ScrollTo(); .2.s();
    
    using var bitmap = CaptureScreen.Image(e.Rect);
    var ms = new MemoryStream();
    bitmap.Save(folders.Desktop + $"logo/{e.Name.Split("/")[0]}.png");
    bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
    print.it($"<><image \"image:{Convert.ToBase64String(ms.ToArray())}\">");
    ScriptEditor.ShowMainWindow(true);
}


Messages In This Thread
RE: How to take screenshots for UI element? - by birdywen - 05-13-2023, 12:33 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)