Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use clipborad.text to insert text fast?
#1
Hi Dear Gintaras,

Could you please have a look at this code I wrote. It should be much faster if I use the clipboard.text method. But I got failed after spending hours. Could you please check it and point some problem and also give advices? So appreciate your help. 

I write this code to scrape the youtube video information. I couldn't extract all the information once since youtube don't allow to show the upload time information. So I got this done with the help of another website. They all marked in the list. 
 
Code:
Copy      Help
//https://intelx.io/tools?tab=youtube      This site helps to get the upload and other information
//https://www.youtube.com/@laofangDDD/videos    This is the site I will use to extract video information

// This code should work but a little bit slow
print.clear();
keys.send("Ctrl+Home");

var csv = new csvTable { ColumnCount = 4 };

var w = wnd.find(1, "老房叨叨叨 - YouTube - Google Chrome", "Chrome_WidgetWin_1");
w.Activate();
var x = wnd.find(1, "Tools - Intelligence X - Google Chrome", "Chrome_WidgetWin_1");
var z = x.Elm["web:GROUPING", prop: "@id=ytshortOutput"].Find(1);
opt.key.KeySpeed = 1;
foreach (var e in w.Elm["web:LINK", "* by 老房叨叨叨 *"].FindAll()){
    var cells = new string[csv.ColumnCount];
    e.Focus();
    x.Activate();
    var e2 = x.Elm["web:TEXT", "Enter YouTube Video URL"].Find(1);
    e2.SendKeys("Ctrl+A", $"!{e.Value}"); keys.send("Enter");.2.s();
    var title = z.Navigate("fi2").Name;
    var data = z.Navigate("ch6 fi").Name.Split("\n")[1].Split(":")[1].TrimStart();
    var view = z.Navigate("ch6 fi").Name.Split("\n")[10].Split(":")[1].TrimStart();
    
    cells[0] = e.Value;cells[1] = title;cells[2] = data;cells[3] = view;
    csv.AddRow(cells);
    print.it(cells);
    w.Activate();
}
print.it(csv);
csv.Save(folders.Desktop+"老房叨叨叨.csv");
#2
Code:
Copy      Help
// script ""
//https://intelx.io/tools?tab=youtube      This site helps to get the upload and other information
//https://www.youtube.com/@laofangDDD/videos    This is the site I will use to extract video information


print.clear();

var csv = new csvTable();
var w = wnd.find(1, "老房叨叨叨 - YouTube - Google Chrome", "Chrome_WidgetWin_1");
var x = wnd.find(1, "Tools - Intelligence X - Google Chrome", "Chrome_WidgetWin_1");
x.Activate();
var z = x.Elm["web:GROUPING", prop: "@id=ytshortOutput"].Find(1);
string prev = z.Elm["STATICTEXT", "Video ID:*\nViews:*"].Find()?.Name; //prevent getting old result
opt.key.KeySpeed = 1;
foreach (var e in w.Elm["web:LINK", "* by 老房叨叨叨 *"].FindAll()) {
    var e2 = x.Elm["web:TEXT", "Enter YouTube Video URL"].Find(1);
    e2.SendKeys("Ctrl+A", $"!{e.Value}", "Enter");
    
    //this is the slow part, ~180 ms. The speed depends on the website+browser. Canot make faster, but can make reliable at the best possible speed.
    //perf.first();

    100.ms();
    g1: var metadata = z.Navigate("ch6 fi");
    var s = metadata?.Name;
    if (s == null || s == prev || !s.Like("Video ID:*\nViews:*")) { 10.ms(); goto g1; }
    prev = s;
    //perf.nw();
    
    var a = s.Lines();
    var data = a[1].Split(":")[1].TrimStart();
    var view = a[10].Split(":")[1].TrimStart();
    var cells = new string[] { e.Value, z.Navigate("fi2").Name, data, view };
    //print.it(cells);
    csv.AddRow(cells);
}

print.it(csv);
//csv.Save(folders.Desktop + "老房叨叨叨.csv");
#3
Thank you so much~ 

e2.SendKeys("Ctrl+A", $"!{e.Value}", "Enter");  

For this row, how to paste the {e.Value} directly to the input without using send.keys. I guess that will much faster!
#4
opt.key.TextHow = OKeyText.Paste;
#5
WOW.  Very fast (3 time faster) now and never fails.   Heart Heart Heart ​​​​​​​ Heart ​​​​​​​ Heart


Forum Jump:


Users browsing this thread: 1 Guest(s)