Results 1 to 6 of 6

Thread: SendKeys "{Please}"

  1. #1
    Guest

    Angry

    =====================================================
    Hiii Guys

    I want to use sendkeys function to send
    Ctrl+RightShift to any control.
    I used sendkeys "^{RSHIFT}" and "^{RIGHTSHIFT}",but in all it was error occured.

    Can some body help me please?

    With Regards.
    ======================================================

  2. #2
    Lively Member
    Join Date
    Aug 2000
    Location
    quebec
    Posts
    81

    Cool

    To specify keys combined with any combination of the SHIFT, CTRL, and ALT keys, precede the key code with one or more
    of the following codes.

    Key Code
    SHIFT +
    CTRL ^
    ALT %
    MSDN Doc.
    C/C++,Delphi,VB6,Java,PB (blech!),ASP,JSP,SQL...bla bla bla and bla
    I love deadlines. I like the whooshing sound they make as they fly by.
    —Douglas Adams

  3. #3
    Guest
    SendKeys cannot distinguish Left and Right shift, hence, you can use PostMessage() as a work around.

    (NOTE: This will only work in Windows NT)
    Code:
    Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Private Const WM_KEYDOWN = &H100
    Private Const WM_KEYUP = &H101
    Private Const VK_RSHIFT = &HA1
    Private Const WM_CHAR = &H102
    
    Private Sub Command1_Click()
        PostMessage Text1.hwnd, WM_KEYDOWN, VK_RSHIFT, 0
        PostMessage Text1.hwnd, WM_CHAR, VK_RSHIFT, 0
        PostMessage Text1.hwnd, WM_KEYUP, VK_RSHIFT, 0
    End Sub

  4. #4
    Guest
    hitcgar, that's not quite what he wants to do. He wants to click the right shift.

    Try this:

    Code:
    Declare Function SendMessage Lib "user32" _
    Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As _
    Long, ByVal wParam As Long, lParam As Any) As Long
    
    Public Const WM_KEYDOWN = &H100
    Public Const WM_KEYUP = &H101
    Private Const VK_RSHIFT = &HA1
    
    Private Sub Command1_Click()
    dwnrshift% = SendMessage(hwnd, WM_KEYDOWN, VK_RSHIFT, 0)
    dwnrshift% = SendMessage(hwn, WM_KEYUP, VK_RSHIFT, 0)
    End Sub
    (Fix the &H100 to make it work correctly)

  5. #5
    Guest
    Matthew: SendMessage will not work because it does not return directly. Use PostMessage instead.

  6. #6
    Guest
    Oh.

    By the way, the reason I posted that was because I hit post reply, and went to look for an answer, and it took me about 20 minutes to find it and I saw that you posted. But thanks again for another tip Megatron .

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