Simple question, I hope:
How do I "click" a radio button from a currently open browser, not WebBrowser1?
Sample Code:
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.
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"
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
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
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"