Results 1 to 6 of 6

Thread: Question to "sendkeys"

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Posts
    2

    Question to "sendkeys"

    Hello,
    I use sendkeys to simulate a key-press to antother application. It works fine.
    Now, I need the simulation of pressing Ctrl+Enter at the same time. How can I do this? It doesn´t works at this time. I tried ^{ENTER} and ^({ENTER}), and ^~ and ...
    Can some one help me?

    The other simulation is: shift+Ctrl+right arrow. And all this at the same time.

    Do you have an idea?

    Greetings Jochen

    PS: The application is a videocutting programm, and i like to simulate the funktions "transition, fast forward, render, ....

  2. #2
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    Something like this does control enter!

    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

    Private Sub Timer1_Timer()
    If GetAsyncKeyState(vbKeyShift) <> 0 And GetAsyncKeyState(vbKeyReturn) <> 0 Then
    Call addnew 'this is my sub. put your function all or
    'whatever here
    End If
    End Sub

    Hows that?

  3. #3
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    I tested the Ctrl Enter combination with this code

    VB Code:
    1. Private Sub Command2_Click()
    2.     Text1.SetFocus
    3.     SendKeys "^{ENTER}"
    4. End Sub

    worked just fine.
    -= a peet post =-

  4. #4
    Matthew Gates
    Guest
    For multiple keys, you can use the keybd_event API function.


    VB Code:
    1. Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As _
    2. Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal _
    3. dwExtraInfo As Long)
    4.  
    5. Const KEYEVENTF_KEYUP = &H2
    6. Const VK_SHIFT = &H10
    7. Const VK_CONTROL = &H11
    8.  
    9. Private Sub Command1_Click()
    10.     keybd_event VK_SHIFT, 0, 0, 0  
    11.     keybd_event VK_SHIFT, 0, KEYEVENTF_KEYUP, 0
    12.     keybd_event VK_CONTROL, 0, 0, 0  
    13.     keybd_event VK_CONTROL, 0, KEYEVENTF_KEYUP, 0  
    14.     keybd_event vbKeyRight, 0, 0, 0  
    15.     keybd_event vbKeyRight, 0, KEYEVENTF_KEYUP, 0  
    16. End Sub

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Posts
    2
    Hello together,
    thanks for the reply.

    Beacon:
    I think you understood me wrong. i wouldn´t press the keys on the keyboard, i will simulate this by clicking a command button

    Peet:
    SendKeys "^{ENTER}" looks fine. Works very good, and so simple. Thank you

    Matthew:
    I have a code like this:

    Private sub command1_click()
    appactivate "Microsoft Word"
    sendkeys {RIGHT}
    end sub

    now, i would instead the keypress "right arrow" press a combination like this: hold down shift key, hold down ctrl key, press once right arrow and release the shift and ctrl keys when the mousebutton comes up.
    Can you explain me, if this is done by your code? I don´t understand the function of your code. Can you put remarks at each line and describe what the line is doing?

    Best greetings
    Jochen from Germany
    (Sorry for my english)

  6. #6
    Matthew Gates
    Guest
    VB Code:
    1. Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As _
    2. Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal _
    3. dwExtraInfo As Long)
    4.  
    5. Const KEYEVENTF_KEYUP = &H2
    6. Const VK_SHIFT = &H10
    7. Const VK_CONTROL = &H11
    8.  
    9. Private Sub Command1_Click()
    10.     AppActivate "Microsoft Word"
    11.     DoEvents
    12.     keybd_event VK_SHIFT, 0, 0, 0  
    13.     keybd_event VK_SHIFT, 0, KEYEVENTF_KEYUP, 0
    14.     keybd_event VK_CONTROL, 0, 0, 0  
    15.     keybd_event VK_CONTROL, 0, KEYEVENTF_KEYUP, 0  
    16.     keybd_event vbKeyRight, 0, 0, 0  
    17.     keybd_event vbKeyRight, 0, KEYEVENTF_KEYUP, 0  
    18. 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