Announcement

Collapse
No announcement yet.

Sendkeys to an embedded app?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sendkeys to an embedded app?

    Okay i can't for the life of me, figure out how to sendkeys to an embedded app...I tried using Appactivate, but that only works when the app is not embedded... Any help would be appreciated...

    Ps I code in VB6

    Never Mind i got it..

  • #2
    What did you do?

    Im sure someone will eventually want to know this and search for it, perhaps even myself if I do my own coding.

    Please share if you can

    Comment


    • #3
      Originally posted by Junglekid27 View Post
      What did you do?

      Im sure someone will eventually want to know this and search for it, perhaps even myself if I do my own coding.

      Please share if you can

      always good to know
      CarPuter Progress:
      Planning:-----> [||||||||||] 100%
      Hardware Buying:-> [||||||||||] 100%
      Software:-----> [||||||||||] 100%
      Installing:-----> [||||||||||] 100%
      Current Project= Making skins in photoshop...

      Comment


      • #4
        http://vb.mvps.org/samples/project.asp?id=sendinput

        Comment


        • #5
          I believe you will need to send a windows event message to the application with the keypress event.

          SendMessage(windowHandle, WM_KEYDOWN, Key, 0)

          and the app needs to be wired up to accept the KeyDown event.
          --------------------------
          Software Developed:
          DS-ATX Controller Interface
          Laptop Shutdown Controller

          Considered Projects:
          TPMS Interface
          Bluetooth Handsfree Interface (WIDCOMM/BROADCOMM)

          Comment


          • #6
            The keybd_event api is also good for this, if you have strings of key commands you need to pass.

            Code:
            
            ''''''''
            Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
            Private Const KEYEVENTF_EXTENDEDKEY As Long = &H1
            Private Const KEYEVENTF_KEYUP       As Long = &H2
            Private Const VK_SHIFT    As Long = &H10
            Private Const VK_CONTROL  As Long = &H11
            Private Const VK_MENU     As Long = &H12
            Private Const VK_SPACE    As Long = &H20
            Private Const VK_PRIOR    As Long = &H21
            Private Const VK_NEXT     As Long = &H22
            Private Const VK_UP       As Long = &H26
            Private Const VK_DOWN     As Long = &H28
            
            Private Declare Function VkKeyScan Lib "user32" Alias "VkKeyScanA" (ByVal cChar As Byte) As Integer
            ''''''''
            
            
            
            Public Sub Keyboard_PressKey(ByVal key$, Optional ByVal HoldShift As Boolean = False, Optional ByVal HoldCtrl As Boolean = False, Optional ByVal HoldAlt As Boolean = False)
            
            'this procedure uses the byte values for key presses to simulate actual keypresses.
            'for now, it's only set up to handle one character at a time.
            
            Dim k As Byte
            
            On Error Resume Next
            
            Dim holdByte As Byte
            holdByte = CByte(Asc(key$))
            k = VkKeyScan(holdByte) And &HFF
            
            
            If HoldShift <> False Then keybd_event VK_SHIFT, 0, KEYEVENTF_EXTENDEDKEY, 0
            If HoldCtrl <> False Then keybd_event VK_CONTROL, 0, KEYEVENTF_EXTENDEDKEY, 0
            If HoldAlt <> False Then keybd_event VK_MENU, 0, KEYEVENTF_EXTENDEDKEY, 0
            
            keybd_event k, 0, KEYEVENTF_EXTENDEDKEY, 0
            keybd_event k, 0, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
            
            If HoldShift <> False Then keybd_event VK_SHIFT, 0, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
            If HoldCtrl <> False Then keybd_event VK_CONTROL, 0, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
            If HoldAlt <> False Then keybd_event VK_MENU, 0, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
            
            End Sub

            Or, get more code: I posted a bunch at:
            http://www.mp3car.com/vbulletin/soft...-attached.html

            Comment

            Working...
            X