needs help automating WebBrowser

aff219

New member
Joined
Oct 9, 2012
Messages
1
Programming Experience
Beginner
Disclaimer: I'm a noob to programming, just got a load of freetime (became self employeed woo!) and decided to learn something I've always wanted to learn. Therefore, I need gentle yet thorough guidance please.

I decided to join a browser based game (name will be left out in all this) and use it as a learning block for this.

I've accomplished quite a lot in my program, but I'm stuck between a rock and a hard place now.

2 big issues I'm having:

Issue 1 - Locating target values and navigating to their assigned URL.

Relevent HTML Code:
VB.NET:
<map name="ValueMap">
     <area alt="USE B 11" href="region.php?reg=2">
     <area alt="open" href="region.php?reg=3">
     <area alt="open" href="region.php?reg=4">
     <area alt="USE C 324" href="region.php?reg=5">
     <area alt="open" href="region.php?reg=6">
     <area alt="USE D 32" href="region.php?reg=7">
     <area alt="open" href="region.php?reg=8">
     <area alt="open" href="region.php?reg=9">
     <area alt="open" href="region.php?reg=10">
     <area alt="open" href="region.php?reg=11">
     <area alt="open" href="region.php?reg=12">
</map>

Notes:
the Alt value is able to contain similar and exact terms as each other. For instance, 2 may be "open", some might be "use b 11", some might be "use b 12" etc


What I want:
1.navigate webbrowser1 to the url contained in the first area tag that has an alt with my searched value.

So if I want to find "D", the program will grab
<area alt="USE D 32" href="region.php?reg=7">
and use its url to navigate in the web browser.

I've had partial success with this with 3 different methods, but all lead to an issue i cant get around so I'm willing to start fresh. The best way ive had yet was with this code:

VB.NET:
Dim Items = _
( _
From T In Form2.WebBrowser1.document.GetElementsByTagName("alt").Cast(Of HtmlElement)() _
Where T.GetAttribute("href").ToString.Contains("region.php?reg=") _
Select Link = T.GetAttribute("href"), Text = T.InnerText _
).ToList
ListBox1.Items.AddRange(Items.ToArray)


But frankly I couldn't figure out how to use that information to navigate to URL (It also seemed to pull more than purely the url, instead of JUST the url it would display "url = ********* Text=" and i couldnt figure out how to fix that, nor could I figure out how to use it to navigate the webbrowser to the page it obtained, then while trying for a few hours I somehow managed to break it <.<

2. click a button on the page it navigates to from goal 1 if 2 variables are true
variable 1: if ____ is located in the HTML code
variable 2: if it states "USE 2" & >= predefined number

seems easy enough right? theres tons of guides on the net for this sort of thing, but for lord only knows why, I can't make it work for this site. I can with others, not this one.

relevant HTML (The form/html code for the button):

VB.NET:
<form method="post" action="region.php">
   <td align="center"><br><br>
<input type="hidden" name="regionId" value="2">
<input type="hidden" name="transId" value="7457995">
	<input type="hidden" name="ownerName" value="USE D">
<input type="submit" value="gain!" name="submit4221" style="color: #FF0000; font-family: Verdana; font-size: 10pt; font-weight: bold; background-color: #FFFFFF">
<input type="hidden" name="action" value="gain">
</td>
</form>

the value="USE D" is a variable that will change but i dont htink it matters
name="submit4221" is a partial variable, the digits at the end can change per page load (wont always)

i've tried about 3 different things, all i can say is submitting a click doesnt seem to accomplish diddly.


Can anyone here give me any tips? I've been at this for over a week and I can't seem to find anything to get me over these hurdles, lots and lots of googling and a forum or two have helped me get this far, but i never seem to get these questions answered

*** actually therse one more noobie question i have, what is the best way to tell your program to wait for webpage1 to finish loading before continuing, WITHOUT coding things directly into the webpage (i don't intend to have it in use and dont want to code directly to it, eventually i want to remove it completely once i get this beta version finished)

I've read a few ways but none seem to be perfect answers
 
Back
Top