Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying Cliboard Items to Listbox automaticly 1

Status
Not open for further replies.
Jun 15, 2003
8
US
When a user rightclicks and selects copyshort cut on a web page I would like to capture that data and have it automticly add/populate a listbox. Then when a user clicks a button have the whole contents wrote to a text file.

I was able to do this in vb6 per this topic
thread222-576513 now i am unable to convert/format it to vb.net code.

What Im using now involves the user clicking a button everytime they add a new shortcut, its kinda defetes the purpose of my app :)
================================
Private Sub cmdLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLoad.Click

Dim d As IDataObject = Clipboard.GetDataObject()
Dim SW As IO.TextWriter

SW = IO.File.AppendText("C:\UbbImage.txt")

SW.WriteLine(CStr("[image]") & (d.GetData(DataFormats.Text) & ("[/image]")))

lstClipboard.Items.Add(CStr("[image]") & (d.GetData(DataFormats.Text) & ("[/image]")))

SW.Flush()
SW.Close()

End Sub
=============================

Thank you all very much for all the great help and advice.

 

Code for copying cliboard item to Listbox:


If Not System.Windows.Forms.Clipboard.GetDataObject() Is Nothing Then
Dim oDataObj As IDataObject = System.Windows.Forms.Clipboard.GetDataObject()
If oDataObj.GetDataPresent(System.Windows.Forms.DataFormats.StringFormat) Then
Dim oStrObj As String = oDataObj.GetData(DataFormats.StringFormat, True)
ListBox1.Items.Add(oStrObj)
End If
End If

 
Thank you.
Now my problem is I dont know how to make this persistant, that is ,I have to create an event that will make this run.

If I loop it, it will loop the same shortcut and crash.

I need it to check if the same data in the listbox is the same data in the clipboard if so wait untill new data is copied to the clipboard then adds the sequential
data.


So basicly Im asking how I cant get this to check for new clipboard data and add it to the listbox. Without having to press a button.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top