What I'm trying to do is load a webpage, do some automated action and then highly text and copy it to the clipboard.
My code works up to highlighting the text (in step 3). If I run the program up to this point and then manually press control_C the text get placed on the clipboard.
However the code in step 4 is not placing the text in the clipboard. This should be a simple step. Am I making some stupid mistake?
Code:Private Sub Tim_events_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tim_events.Tick Static steps As Int16 = 1 If steps = 1 Then 'step 1: wait for the page to load 'then pause one time tick Try Dim dummy = WebBrowser.Document.Window() Catch ex As Exception 'page has not finished loading 'wait Return End Try Tim_events.Interval = 2500 ElseIf steps = 2 Then 'step 2: click radio button to get numbers 'schroll browser WebBrowser.Document.Window.ScrollTo(75, 400) 'move mouse SetCursorPos(165, 119) 'click mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) Tim_events.Interval = 5000 ElseIf steps = 3 Then 'step 3: highlight desired text on browser ' ''schroll browser WebBrowser.Document.Window.ScrollTo(0, 550) 'move mouse SetCursorPos(16, 99) 'mouse down mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) 'move mouse (drag) SetCursorPos(46, 114) 'mouse up mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) Tim_events.Interval = 5000 ElseIf steps = 4 Then 'step 4: copy to clip board by simulating type control_c SendKeys.Send(Chr(3)) Tim_events.Interval = 3000 'ElseIf steps = 5 Then ' 'step 5: give focus to textbox ' Txt_workbox.Focus() ' Tim_events.Interval = 1500 'ElseIf steps = 6 Then ' step 6 paste data ' SendKeys.Send(Chr(22)) ' Tim_events.Interval = 500 ElseIf steps = 7 Then 'step 7 Process data 'to do ...... steps = -1 Tim_events.Stop() Tim_events.Interval = 500 End If steps += 1 End Sub


Reply With Quote