Results 1 to 4 of 4

Thread: do CTRL + V (Paste)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2009
    Posts
    20

    do CTRL + V (Paste)

    I have a dialog box that pops up from a webbrowser window when i invoke click.

    I have copied a filepath to the clipboard but does anyone know how i can do a ctrl + v to paste the text into the dialog filename window.

    I have tried sendkeys but didnt work

  2. #2
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: do CTRL + V (Paste)

    Quote Originally Posted by stewmath View Post
    I have a dialog box that pops up from a webbrowser window when i invoke click.

    I have copied a filepath to the clipboard but does anyone know how i can do a ctrl + v to paste the text into the dialog filename window.

    I have tried sendkeys but didnt work
    It is not a good idea to copy text into a user's clipboard as you are overwriting their data. A better idea is to set the file path into the dialog directly. Where you are copying the file name into the clipboard copy it instead to a variable. When the dialog is ready to display place the info from the variable into the dialog.

    Declare the variable
    Code:
    Private FilePath As String = ""
    At some point set the variable then use it.

    Code:
    MyOpenDialog.InitialDirectory = FilePath

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2009
    Posts
    20

    Re: do CTRL + V (Paste)

    The only problem with your suggestion is that its not actually my dialog box thats open. Its one from a website, im using the invoke click method in a webbrowser control to click a browse box in a form.

  4. #4
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: do CTRL + V (Paste)

    Quote Originally Posted by stewmath View Post
    The only problem with your suggestion is that its not actually my dialog box thats open. Its one from a website, im using the invoke click method in a webbrowser control to click a browse box in a form.
    Seems like you will need to look at obtaining the window handle of the text box in question using VS Spy++ using either FindWindow or FindWindowEx API functions followed by SetDlgItemText API to set the text.


    The following is not a solution but some code showing how to work with window handles.
    http://www.vbforums.com/showpost.php...74&postcount=2


    SetDlgItemText
    Code:
        Public Declare Function SetDlgItemText Lib "user32.dll" Alias "SetDlgItemTextA" ( _
            ByVal hDlg As Integer, _
            ByVal nIDDlgItem As Integer, _
            ByVal lpString As String) As Integer
    
        Public Const IDC_TEXT As Long = 1000
    Code should look something like this
    Code:
    SetDlgItemText(hwnd, IDC_TEXT, "This is a string")
    I have not done this before (set text as you want in vb.net), the code above all came from searching via Google for about five minutes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width