Question selecting unknown text from webbrowser

steb

New member
Joined
Aug 7, 2016
Messages
1
Programming Experience
1-3
Question : how do I select uknown/randomized text from a webbrowser using a win form.


Details: for example: there's a website that gives people pin/serial for something in the shoutbox/chat box. Now I want to make something in c# that can automatically copy the serial number. (example of serial number : Serial-JDN258HDN4)


Problem: the letters & numbers are randomized, is there a way I can select the serial code automatically using c#. Also, is there a way I can just find the 'Serial-' then just select the randomized code after it.


Problem2: the bot i made only selects the "Serial-" not the code after it!


What I've done : I tried doing ihtmltxtrange.findtext but it only selected the text 'SERIAL-' and not the code after it.


Code :::::::::::: serial = bsn
(edited. to help me, please help me edit my code so that it automatically selects the "BSN-" and the uknown number after it from webbrowser. Thank you in advance)


NOTE : THE Length of NUMBER+LETTERS AFTER "SERIAL-" is always 10


private void method1()
{
if (webBrowser1.DocumentText.Contains("BSN-"))
{
list.Items.Add(DateTime.Now.ToShortDateString() + "T> Found Text You Looking For");
if (webBrowser1.Document != null)
{
IHTMLDocument2 document2 = webBrowser1.Document.DomDocument as IHTMLDocument2;
if (document2 != null)
{
IHTMLSelectionObject currentSelection = document2.selection;


IHTMLTxtRange range = currentSelection.createRange() as IHTMLTxtRange;
if (range != null)
{
const String search = "BSN-";
const String XXXXXX = "XXX-XXXXXXXXXX";
//XXXXXX.Length //582
if (range.findText(search, 14, 0))
{
list.Items.Add(DateTime.Now.ToShortDateString() + "T> Found range search");
range.select();
webBrowser1.Document.ExecCommand("Copy", false, null);
nsTextBox1.Text = Clipboard.GetText();
nsTextBox1.Text = range.text;
}
else
{
list.Items.Add(DateTime.Now.ToShortDateString() + "T> Coudlnt find range");
}
}
}
}
}
}
 
Back
Top Bottom