1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Attaching to a Process?

Discussion in 'Software Development' started by iLee, Jan 11, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. iLee

    iLee Thread Starter

    Joined:
    Jan 21, 2009
    Messages:
    52
    Could anybody help me on this predicament? I need to attach my program to a process named 'gunbound.gme' So I can use the 'SendKeys.Send(TextBox1.Text)'

    Any help is appreciated.

    I'm using Visual Basics 2010.
     
  2. -Fabez-

    -Fabez-

    Joined:
    Jul 28, 2008
    Messages:
    1,899
    The SendKeys function will send the keys you specify to the active window, so if gunbound.gme has focus then the keys will be sent to that application. This means that you do not have to attach your program to it's process, rather ensure that it runs when gunbound.gme has focus.
     
  3. iLee

    iLee Thread Starter

    Joined:
    Jan 21, 2009
    Messages:
    52
    But in doing so, when I switch to gunbound.gme, none of the SendKeys work once switching to that process, however if I switch out, it'll work.
     
  4. -Fabez-

    -Fabez-

    Joined:
    Jul 28, 2008
    Messages:
    1,899
    When you switch to the gunbound.gme process, the program you have created will continue to run, so it is still capable of sending the keys you want to. Do you have any code so far ?
     
  5. iLee

    iLee Thread Starter

    Joined:
    Jan 21, 2009
    Messages:
    52
    PHP:
    Public Class Form1

        
    Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button1.Click
            AutoType
    .Interval = (TextBox4.Text)
            
    AutoType.Enabled True
        End Sub

        
    Private Sub Button2_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button2.Click
            AutoType
    .Enabled False
        End Sub

        
    Private Sub Button3_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button3.Click
            MessageBox
    .Show("Type what you want to say in the TextBoxes, and tick the Checkboxes that you want to say. Then click start and open your Application, I am currently working on Hotkeys, to enabled while using an Application. Click Start and Stop for obvious reasons.")
        
    End Sub

        
    Private Sub AutoType_Tick(ByVal sender As System.ObjectByVal e As System.EventArgsHandles AutoType.Tick
            
    If CheckBox1.Checked True Then
                SendKeys
    .Send(TextBox1.Text)
                
    SendKeys.Send("{Enter}")
            
    End If
            If 
    CheckBox2.Checked True Then
                SendKeys
    .Send(TextBox2.Text)
                
    SendKeys.Send("{Enter}")
            
    End If
            If 
    CheckBox3.Checked Then
                SendKeys
    .Send(TextBox3.Text)
                
    SendKeys.Send("{Enter}")
            
    End If
        
    End Sub
    End 
    Class
    Well, the code works fine, as I've tried it. But whenever I switch to Gunbound.gme it continues in another process, because for some reason it doesn't fully switch to it. Which Is why I need to attach it to the process.
     
  6. -Fabez-

    -Fabez-

    Joined:
    Jul 28, 2008
    Messages:
    1,899
    If the code works fine and sends the key as expected, what do you mean by it doesn't fully switch to it ? Here is the MSDN documentation for the SendKeys.SendWait() method, the first note should help with targeting the correct window.
     
  7. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/973988

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice