CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 1999
    Posts
    3

    how can i send keys

    how can i send keys from my application to any other programe that i make active by mouse clicking. or i have to use the z-order method to find second active programe?


  2. #2
    Join Date
    Oct 1999
    Location
    Holland
    Posts
    34

    Re: how can i send keys

    Use SendKeys (Check the online help for details), it's very easy to use. Unfortunatly I don't have sample-projects at this time, sorry.


  3. #3
    Guest

    Re: how can i send keys

    This is an example with Windows Dialer (some of elements are not shown):

    private Sub Dial()
    'FindWindow and SetWindowPos& are API finctions declared as public in a module
    Dim lngReturnValue as Long
    lngReturnValue = FindWindow("DialerClass", vbNullString)
    'make Dialer the most top form
    lngReturnValue = SetWindowPos&(lngReturnValue, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)

    'create DialNumber depending on area code. Variable intListIndex is used to determine which lstAccountPhone is highlighted
    If Left(lstAccountPhone(intListIndex).Text, 7) <> " (" & strAreaCode & ")" then 'check whether the area code is a local
    DialNumber = "1" & lstAccountPhone(intListIndex).Text 'add 1 and use full entry from the field PhoneNumber
    else
    DialNumber = Right(lstAccountPhone(intListIndex).Text, 8) ' if area code is local, use only last 7 digits (plus one dash) from the phoneNumber
    End If
    'there are List Boxes on the form, but for testing you can set DialNumber variable directly, for example DialNumber = "718-743-1210"
    SendKeys DialNumber, true
    SendKeys "{Enter}", true
    End Sub



    HTH
    Vlad



  4. #4
    Join Date
    Oct 1999
    Posts
    3

    Re: how can i send keys

    thanks, but the problem is that how can i make the last active window active from my programe. for example
    i am using note pade, then i started my programe, now active window is my programe, i press a button in my programe, and the keys
    r send to notepade


  5. #5
    Join Date
    Oct 1999
    Posts
    3

    Re: how can i send keys

    thanks, but the problem is that how can i make the last active window active from my programe. for example
    i am using note pad, then i started my programe, now active window is my programe, i press a button in my programe, and the
    keys r send to notepad


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

Featured