Results 1 to 8 of 8

Thread: SendKeys?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    Unhappy

    Is there an API that mimics what sendkeys does? I guess appactivate also
    Chris

    chrisderson@ameritech.net
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Maybe keybd_event?
    Oetje
    oetje@home.nl
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  3. #3
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Sorry, use SendInput instead.
    Oetje
    oetje@home.nl
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    hmmm

    But what about appactivating?
    Chris

    chrisderson@ameritech.net
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  5. #5
    Guest
    For AppActivating, you can either use the FindWindow orSetForegroundWindow or SetFocus API functions.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    hmm

    Can I give setfocus a filepath as opposed to a hwnd?
    Chris

    chrisderson@ameritech.net
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  7. #7
    Guest
    For AppActivating, use SetForegroundWindow. For SendKeys, use SendMessage to sent the WM_CHAR or WM_KEYDOWN event.

  8. #8
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Thumbs up

    Chris_SE, Jux put this code in the basic module file will automatic setfocus to the application, although the application wwindow is in miniminzed stage.

    Code:
    Option Explicit
    Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As String) As Long
    Private Const SW_SHOWNORMAL = 1
    
    Sub Main()
        'Assume your default form is Form1 with tital = "MyApp"
        Dim hwnd As Long
        Dim x As String
    
        x = "MyApp"
        hwnd = FindWindow(0, x)
        If hwnd <> 0 Then
            AppActivate x
            ShowWindow hwnd, SW_SHOWNORMAL
            Exit Sub
        End If
        Load Form1
        Form1.Show
    End Sub

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