CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2001
    Location
    Venezuela
    Posts
    23

    Question can´t simulte the spacebar key

    I have a problem on a code i`m building, i need to simulate pressing the space bar key on a control Button that was built as an ActiveX but it doesnt allows to select it by pressing any other keys than the space bar.


    Does anyone know how coul i make this work???.

  2. #2
    Join Date
    Sep 2001
    Location
    Québec, Canada
    Posts
    1,923
    Set the focus on your control and use SendKey to send the spacebar key, should workl...

    JeffB

  3. #3
    Join Date
    Jan 2001
    Location
    Venezuela
    Posts
    23

    Question space bar key code

    My problen is because i didnt find any code for the spacebar key; does anyone knows wich is it, for the sendkeys function???

  4. #4
    Join Date
    Sep 2001
    Location
    Québec, Canada
    Posts
    1,923
    Space is 32

    JeffB

  5. #5
    Join Date
    Jan 2001
    Location
    Venezuela
    Posts
    23

    Unhappy Example

    Hi,

    I tried it but it didn´t work, this is how i used it:

    sendkeys "32"

    is this correct???

    Thanks,

  6. #6
    Join Date
    Jan 2002
    Location
    Quebec/Canada
    Posts
    124
    SendKeys " " ?

    Heulsay

  7. #7
    Join Date
    May 2002
    Location
    Montreal
    Posts
    450
    Untested...
    Maybe you can try SendKeys Chr(32)

    How about SendKeys {SPACE} or
    SendKEys {SP}.
    That is not in the online help.

    Cheers,
    Laurent

  8. #8
    Join Date
    Sep 2001
    Location
    Québec, Canada
    Posts
    1,923
    That works, it send the key "SPACE" to the command2 command button, and the msgbox pop up

    Code:
    Private Sub Command1_Click()
        Me.Command2.SetFocus
        SendKeys " "
    End Sub
    
    Private Sub Command2_Click()
        MsgBox "pressed"
    End Sub
    JeffB - hope it helps

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

Featured