Results 1 to 6 of 6

Thread: How to set focus to an object in a Form?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2009
    Posts
    127

    Question How to set focus to an object in a Form?

    I’m making program with Shockwave Flash Object inside. Flash object generates text that can be highlighted and copied. I’m trying to click on flash text and select it but don’t happen, I think it’s because Flash object is out of focus so send keys doesn’t work.

    Here is my code:
    Code:
            Clipboard.Clear()
            Activate()
            Windows.Forms.Cursor.Position = New System.Drawing.Point(31 + Me.Bounds.X, 354 + Me.Bounds.Y)
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
            SendKeys.Send("^a")
            System.Threading.Thread.Sleep(100)
            SendKeys.Send("^c")
    What should I do? or is here another way?
    VB n00b with stupid questions
    Home site keywen.com

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Jul 2009
    Posts
    127

    Re: How to set focus to an object in a Form?

    Please help I reaaaaaaaaaaaaaaaaaaaaly need this
    VB n00b with stupid questions
    Home site keywen.com

  3. #3
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,390

    Re: How to set focus to an object in a Form?

    flashcontrol.focus ??

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 2009
    Posts
    127

    Re: How to set focus to an object in a Form?

    flashcontrol.focus gives our error, not declared
    VB n00b with stupid questions
    Home site keywen.com

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2009
    Posts
    127

    Re: How to set focus to an object in a Form?

    OK I did this instead


    Code:
     Clipboard.Clear()
    
            Windows.Forms.Cursor.Position = New System.Drawing.Point(31 + Me.Bounds.X, 354 + Me.Bounds.Y)
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
            Windows.Forms.Cursor.Position = New System.Drawing.Point(65 + Me.Bounds.X, 382 + Me.Bounds.Y)
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
            Activate()
    
            Windows.Forms.Cursor.Position = New System.Drawing.Point(198 + Me.Bounds.X, 181 + Me.Bounds.Y)
            mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
            Windows.Forms.Cursor.Position = New System.Drawing.Point(228 + Me.Bounds.X, 250 + Me.Bounds.Y)
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
    
    
            Me.Activate()
            Me.TextBox31.Focus()
            TextBox31.Text = TextBox31.Text.Replace("%", "")
    Instead of clicking ^a ^c it double clicks on text to select it, then right click on it and chose copy. Then it goes to a text box and does right click on it and chose paste text.

    But after this I can’t work with textbox text why? I can’t do this
    Code:
    TextBox31.Text = TextBox31.Text.Replace("%", "")
    It wont replace text!!! PLEASE HELP ME
    Last edited by nusaki; Aug 6th, 2009 at 09:21 PM.
    VB n00b with stupid questions
    Home site keywen.com

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jul 2009
    Posts
    127

    Re: How to set focus to an object in a Form?

    Can someone help me please I’m been trying to do this for over a week
    VB n00b with stupid questions
    Home site keywen.com

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