Click to See Complete Forum and Search --> : Simulate keys pressed using API?
yveskreis
Jul 7th, 2000, 09:07 AM
My only access to the window is through SendMessage. I am able to post any text, now I want to simulate keys...
1) I can't send any ENTER key character to the edit control.
2) Is it possible in any way to simluate i.e. ALT+R?
Best Regards,
Yves
BFord
Jul 8th, 2000, 01:50 AM
1) to send ENTER to the edit control, you should just find the character for enter.......i think it might be chr(10) or maybe even chr(12)
send this text to the edit control:
"Line 1" & chr(10) & "Line 2"
2) i'm assuming that by sending Alt-R, you are trying to get into a menu....to do that use the GetMenu and GetSubMenu functions
yveskreis
Jul 9th, 2000, 06:17 AM
1) I tryed both and even the vbNewline one, they don't work! Else I would not have asked...
2) I am trying to run a Keyboard Express macro using ALT+R... Is there a way to simulate keys so that this would be possible?
Best Regards,
Yves
Try using the keybd_event or SendInput API.
yveskreis
Jul 12th, 2000, 04:25 AM
I am using SendMessage(hwnd, WM_CHAR, 13, 0) to send the Return key! Did not try but maybe I can simulate ALT+R the same way!
Best Regards,
Yves
spidermanag
Jul 19th, 2000, 04:12 AM
USE THIS CODE
Option Explicit
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 VK_ENTER = &HD
Private Const KEYEVENTF_KEYUP = &H1
Private Sub Form_Load()
Form1.Visible = False
Dim VK_ACTION As Long
VK_ACTION = &H52
Call keybd_event(VK_ACTION, 0, 0, 0)
Call keybd_event(VK_ALT, 0, 0, 0)
End Sub
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.