Results 1 to 3 of 3

Thread: Using sendkeys and AppActivate

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    the UK
    Posts
    265

    Post

    I'm using Sendkeys to send foreign characters to MS Word Eg:

    Private Sub cmdj_Click()
    AppActivate "Microsoft Word"
    SendKeys Chr$(251), True
    End Sub

    But what I really want is for this to work with any Win 9x/NT app that happens to be open NOT just MS Word.

    Any ideas anyone

    Simon

  2. #2
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Post

    Well, just pass the title of the window you want to send the keys to!

    To get the title, use GetWindowText function to get the title bar text. You need to know the window's handle for this. If you don't know the handle, use EnumWindows to get handles of all top-level windows. You can then either SendKeys to each window using a loop, or search for a particular class or title of window, or use GetForegroundWindow function to send the keys to the window the user is currently working with.

    Hope this helped a little.

    Go to:

    http://www.vbapi.com/ref/funcc.html#windowclasses

    for details on most common APIs dealing with windows.

    ~seaweed

  3. #3
    Lively Member
    Join Date
    Jan 2000
    Location
    UK
    Posts
    66
    I've been working on this hopelessly for weeks now ;(

    Does anyone have any code that will do what seaweed suggest - particularly using the GetForegroudWindow function.

    Basically, I suppose I need a variable that I can replace "Microsoft Word" with.

    Eg:

    Private Sub cmdj_Click()
    AppActivate currentforegroundapp
    SendKeys Chr$(251), True
    End Sub

    Hope someone can help

    Simon

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