Results 1 to 6 of 6

Thread: Not able to Copy in Clipboard using VBScript

  1. #1
    Join Date
    Aug 2006
    Posts
    168

    Not able to Copy in Clipboard using VBScript

    I am using the notepad for writing the codes in VBScript. Also I don't want to use anything else than the notepad. I am facing a problem while making project. My problem is that I am not able to Copy in Clipboard using VBScript.! I have tried to make coding but that is not coping the things actually. Can someone tell me the coding for that. Please provide me coding as soon as possible.
    Thanks in Advance..
    "All gave some, some gave all."

  2. #2
    Join Date
    Nov 2008
    Posts
    996

    Re: Not able to Copy in Clipboard using VBScript

    I think that it will be better if you provide us the sample of the script that you made for Copying data in Clipboard using VBScript. Because instead of telling you the whole program, it will be better for me (maybe others) to tell you the exact place where you are going wrong.!! Also by that code i can come to know what exactly you want to do.!?! So post us the code..!

  3. #3
    Join Date
    Aug 2006
    Posts
    168

    Re: Not able to Copy in Clipboard using VBScript

    Thanks for replying me and also for trying to solve my problem. I have written script but it does not really copy the data from the clipboard, it will just write it to the file immediately, without copying. Here is my script :
    Code:
    strComputer = "."
        Set objWMI = GetObject("winmgmts:\\" & strComputer & "\cimv2")
        Set colItems = objWMI.ExecQuery _
            ("Select * from Win32_Proxy",,50)
    
    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
    "All gave some, some gave all."

  4. #4
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Not able to Copy in Clipboard using VBScript

    According to me you need a parent window to copy something to the clipboard.
    I think that you should try the following coding :
    Code:
    Set objHTML = CreateObject("htmlfile")
    ClipboardText = objHTML.ParentWindow.ClipboardData.GetData("text")
    MsgBox ClipboardText
    Hope that you will get something after using this script.

  5. #5
    Join Date
    Mar 2008
    Posts
    349

    Re: Not able to Copy in Clipboard using VBScript

    You should try the following code for Copying Data in Clipboard using VBScript. Hope that after creating the object you will able to copy the data. Here is the code for that :
    Code:
    Set objIE = CreateObject("InternetExplorer.Application")  
      
    objIE.Navigate("about:blank")  
    objIE.document.parentwindow.clipboardData.SetData "text", strCopy  
    strCopy = "This text has been copied to the clipboard."  
    
    objIE.Quit

  6. #6
    Join Date
    May 2008
    Posts
    2,012

    Re: Not able to Copy in Clipboard using VBScript

    I have provided you the script. You will have to copy path script with self register function and your problem will get solved.
    Code:
    <!-- FileName:CopyPath.hta -->  
      
    <hta:application ID="HTA" windowstate="maximize">  
      
    <script language=vbs>  
      
    Const TKey1 = "HKCR\*\shell1\CopyPath\", Tkey2 = "HKCR\Directory1\shell\CopyPath\"  
      
    Const sMenu = "Copy FullPath(&F)"  
      
    Dim Arg, 
    Dim pPath, 
      
    Arg = Mid(HTA.commandLine, Len(document.urlunencoded) + 4)  
      
    If Arg = "" Then  
      
    pPath = document.urlunencoded  
      
    Reg_UnReg TKey1, sMenu, pPath, False: Reg_UnReg TKey2, sMenu, pPath, True  
      
    Else  
      
    Me.clipboarddata.setdata "Text", Arg  
      
    End If  
      
    Me.Close  
      
    '  
      
    Sub Reg_UnReg(Key, Menu, Path, PopUp)  
      
    Dim ENo  
      
    With CreateObject("WScript.Shell")  
      
    .SendKeys "{F10}{ESC}", True  
      
    On Error Resume Next: .RegRead Key: ENo = Err.Number: On Error GoTo 0  
      
    If ENo <> 0 Then  
      
    .RegWrite Key, Menu  
      
    .RegWrite Key & "command\", "mshta """ & Path & """ %L"  
      
    If PopUp Then .PopUp "Added to context menu.", 1  
      
    Else  
      
    .RegDelete Key & "command\": .RegDelete Key  
      
    If PopUp Then .PopUp "Deleted from context menu.", 1  
      
    End If  
      
    End With  
      
    End Sub  
      
    </script>
    According to me you should able to copy your data to clipboard using this script.

Similar Threads

  1. Windows 7: ctrl+C cannot copy onto the clipboard
    By The!Winston in forum Operating Systems
    Replies: 5
    Last Post: 02-12-2010, 07:44 AM
  2. Applescript to Copy from Clipboard to Terminal
    By Jensen Ackles in forum Operating Systems
    Replies: 6
    Last Post: 31-07-2010, 06:05 AM
  3. Copy Gantt chart to clipboard
    By !Starr! in forum Microsoft Project
    Replies: 3
    Last Post: 20-04-2010, 08:00 AM
  4. Code to copy to clipboard
    By Brunoz in forum Software Development
    Replies: 3
    Last Post: 24-11-2009, 01:42 PM
  5. Copy an error message to clipboard
    By Erskine in forum Tips & Tweaks
    Replies: 4
    Last Post: 06-02-2009, 11:29 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,283,628.99089 seconds with 17 queries