Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Using vb.net to output text to a browser textbox?
So here is what I'm try to attain:
I current use the signature plug-in for Firefox. I currently use it to manage my canned answers as work. My one dislike of the signature plug-in is that it allows me now way to organize signatures based on something like a category. So I have coded a GUI to organize specific canned answers but I cannot find any way to have the vb.net application push the data out to a text box in a browser web page. To explain to more detail at work our ticketing system is accessed through a browser and so I am trying to get my vb code to output text to the browser.
Also I am trying to also get the application the push specific text on a computer to where ever the text cursor is currently located. If this is an easier option then passing the data to an actual text box on a web page I'll use that option for both functions.
Thanks in advance for any assistance!
1 Answer
- Anonymous1 decade agoFavorite Answer
You can add a reference to the system.web namespace and gain access to the web document model. I was recently working on a similiar idea and did not go the whole way with this because I already had a solution that would work for me. My alternate solution used parts if the Windows API to enter the text at a particular location on the screen.
here are the API declarations for VB.NET
__________________________________________________________
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
Private Const MOUSEEVENTF_MOVE As Integer = &H1 ' mouse move
Private Const MOUSEEVENTF_LEFTDOWN As Integer = &H2 ' left button down
Private Const MOUSEEVENTF_LEFTUP As Integer = &H4 ' left button up
Private Const MOUSEEVENTF_RIGHTDOWN As Integer = &H8 ' right button down
Private Const MOUSEEVENTF_RIGHTUP As Integer = &H10 ' right button up
Private Const MOUSEEVENTF_MIDDLEDOWN As Integer = &H20 ' middle button down
Private Const MOUSEEVENTF_MIDDLEUP As Integer = &H40 ' middle button up
Private Const MOUSEEVENTF_WHEEL As Integer = &H800 ' wheel button rolled
Private Const MOUSEEVENTF_ABSOLUTE As Integer = &H8000 ' absolute move
I used these along with the sendkeys function to enter text to the specific locations.
Here are some sample subroutines that I used
Private Function right_click(ByVal hold As Boolean)
Dim i As Integer
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
' may be necessary to pause here
For i = 1 To 1000
My.Application.DoEvents()
Next
If Not hold Then
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
End If
Return True
End Function
Private Function move_mouse_to_location(ByVal x As Integer, ByVal y As Integer)
Dim desired As Point
Dim current As Point
Dim move As Point
Dim resolution As Rectangle
resolution = My.Computer.Screen.Bounds
If x > 0 And x < resolution.Right Then 'the value is legimate
desired.X = x
Else
MsgBox("The value for the mouse that you passed is out of bounds. X must be a value between 0 and " & resolution.Right & " You passed the value " & x)
desired.X = 0
End If
If y > 0 And y < resolution.Bottom Then
desired.Y = y
Else
MsgBox("The value for the mouse that you passed is out of bounds. Y must be a value between 0 and " & resolution.Bottom & " You passed the value " & y)
desired.Y = 0
End If
move = desired - current
current.X = MousePosition.X
current.Y = MousePosition.Y
While current.Y > desired.Y
mouse_event(MOUSEEVENTF_MOVE, 0, -1, 0, 0)
current.Y = MousePosition.Y
End While
While current.Y < desired.Y
mouse_event(MOUSEEVENTF_MOVE, 0, 1, 0, 0)
current.Y = MousePosition.Y
End While
While current.X > desired.X
mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0)
current.X = MousePosition.X
End While
While current.X < desired.X
mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0)
current.X = MousePosition.X
End While
Return True
End Function
Private Function send_text(ByVal text As String)
Dim i As Integer
SendKeys.Send(text)
For i = 1 To 10000
My.Application.DoEvents()
Next
Return True
End Function