|
-
Apr 30th, 2013, 09:16 PM
#1
Thread Starter
Lively Member
Ready to give up :( ! Radio button...
Simple question, I hope:
How do I "click" a radio button from a currently open browser, not WebBrowser1?
Sample Code:
Code:
Dim btnClick As HtmlElement = WebWindow.WebBrowser1.Document.GetElementById("radiogroup0")
If btnClick IsNot Nothing Then
btnClick.InvokeMember("click")
End If
This code does not work when I load up Chrome (which is my default) and give it focus using the code below, nor with Firefox, IE, or my proxy browser. It only works if I run this code directly through WebBrowser1 in vb.
Code:
'Give browser focus
For Each app As Process In Process.GetProcessesByName("Chrome")
Dim theHandle As IntPtr = FindWindow(Nothing, app.MainWindowTitle)
If theHandle <> IntPtr.Zero Then
SetForegroundWindow(theHandle)
End If
Next
My guess? I have to somehow declare the currently open browser as WebBrowser1, but I think they won't share the same controls so I don't think that will work. I know it's possible to "click" buttons on other apps with VB, so I'm 100% sure this is possible, but how?
BACKGROUND: I'm trying to get this working with a proxy browser and can't change the default browser vb uses to it if that's your first thought, sorry. I've spent the last 16+ hours of my free time trying to find an answer to this and am quite literally at my wits end; I've read through two different Visual Basic Step by Step and Teach Yourself Visual Basic in 24-hours, and so many pages off Google, I honestly don't know where to begin, but ironically I didn't find anything even remotely close to the exact issue I'm having, and hence I have no clue how to proceed. A little "hint" would be nice if you don't want to give me the code.
EDIT: The error code I'm receiving is, "NullReferenceException was unhandled"
Last edited by Taem; Apr 30th, 2013 at 09:32 PM.
Reason: Forgot to give error code
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|