Welcome Guest ( Log In | Register )

Discover the best free computer help!
Learn more about Geeks to Go by taking the tour. Spyware, virus, trojan, fake security or privacy alerts? Read the malware cleaning guide.
      
 
Reply to this topicStart new topic
VBS and the Clipboard., Inputbox content to the clipboard.
IO-error
post Oct 5 2006, 03:34 AM
Post #1


Member
***
Posts: 229
From: the Netherlands
OS: WinXP PRO SP2 [Version 5.1.2600]



Hi there. I ran into a problem with my personal project.

I'm using only Notepad++ and not willing to step to something else. (just so nobody advices me to use something else)

I read all about it on the internet that it's possible to copy something to the clipboard, but every single script that I saw has nothing to do with the clipboard in reality.
The example scripts all use IExplore and about:blank and all kinds of stuff that has nothing to do with it.

Some guy explained to me that it needs a parent window to copy something to the clipboard, but in the example script it will not REALLY copy it, it will just write it to the file immediatly, without copying.

My example:

CODE

strComputer = "."
    Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMI.ExecQuery _
        ("Select * from Win32_Proxy",,48)

For Each objItem in colItems
    ProxyServer = objItem.ProxyServer
    ProxyPortNumber = objItem.ProxyPortNumber
Next

Proxy = InputBox("Do you want to save the IP to disk?.","Here's your IP and Port.",""&ProxyServer &":" &ProxyPortNumber,800,600)

If Proxy = 1 Then
With Clipboard
    .Clear
    .SetText(""& ProxyServer)
End With
    msgbox("Copied")
        Else msgbox("Copy Failed")
End If


First block gets data from the WMI engine, the proxy server/IP.
Second block assigns names to specific data in the WMI engine.
Third block creates my inputbox with the wanted text. (The Proxy IP/Port)
The last block will copy the text to the clipboard when the user clicks OK and if the user clicks cancel or exits script.

The error message I get says that the types don't match.
Go to the top of the page
 
+Quote Post
IO-error
post Feb 13 2007, 03:03 AM
Post #2


Member
***
Posts: 229
From: the Netherlands
OS: WinXP PRO SP2 [Version 5.1.2600]



Hi all.

I gave up on this a long time ago, because nobody knew how to do it.
Now I'm back with more research, but no answers...

CODE

Set objHTML = CreateObject("htmlfile")
ClipboardText = objHTML.ParentWindow.ClipboardData.GetData("text")
MsgBox ClipboardText


This IS working, but I have no idea how to throw in new data.
I tried google, but I get about 190.000 hits... And I tried 150 random links without any luck.
All the scripts I find are for VBA or VB, not VBS. And the one that was for VBS couldn't set data to the clipboard.
Is the clipboard such a newbie area in VBS?

Thnx in advance
Go to the top of the page
 
+Quote Post
IO-error
post Apr 8 2008, 12:47 PM
Post #3


Member
***
Posts: 229
From: the Netherlands
OS: WinXP PRO SP2 [Version 5.1.2600]



For those that were trapped like me:

I managed to get it working and made an easy-to-study layout for those that want VBS to put data on the clipboard.
If you have any questions about VBS, you can PM me for my msn-adres.


CODE
Dim ClipBoard
'msgbox("0")
Set Clipboard = New cClipBoard

ClipBoard.Clear
ClipBoard.Data = "This text is clipboard data."
'MsgBox ClipBoard.Data

Class cClipBoard
    Private objHTML
    
        Private Sub Class_Initialize
            Set objHTML = CreateObject("InternetExplorer.Application")
            objHTML.Navigate ("about:blank")
'            msgbox("1")
        End Sub
        'TODO When to use Get and Let.
        Public Sub Clear()
            objHTML.Document.ParentWindow.ClipboardData.ClearData()
'            msgbox("2")
        End Sub
            
        Public Property Let Data ( Value )
            objHTML.Document.ParentWindow.ClipboardData.SetData "Text" , Value
'            msgbox("3")
        End Property
    
        Public Property Get Data()
            Data = objHTML.Document.ParentWindow.ClipboardData.GetData("Text")
'            msgbox("4")
        End Property

        Private Sub Class_Terminate
            objHTML.Quit
            Set objHTML = Nothing
'            msgbox("5")
        End Sub
        
End Class
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

RSS Time is now: 24th July 2008 - 07:59 PM
Advertisements do not imply our endorsement of that product or service. The forum is run by volunteers who donate their time and expertise. We make every attempt to ensure that the help and advice posted is accurate and will not cause harm to your computer. However, we do not guarantee that they are accurate and they are to be used at your own risk.