Guidance Forums / Rapid-Q Basic / VB sendkeys

Search 搜索
Home Home

Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. VB sendkeys
Posted by: 2002-12-21 06:43:18
Could someone translate the VB code bellow to rapidq ?

Private Sub Command1_Click()
    SendKeys "%{TAB}", False
    SendKeys "%E", False
    SendKeys "A", False
    SendKeys "%E", False
    SendKeys "c", False
End Sub

Message2. RQ sendkeys
Posted by: guidance 2002-12-21 07:10:05
RQ sendkeys example (by win32 api):

By the way, you may try the in-site search here by press alt-s, enjoy :)
Message3. Re: RQ sendkeys
Posted by: 2002-12-22 00:57:13
Sorry but sendkeys.bas doesn't good. I've try before my message.

There are problems that I suppose I have resolved
1 : SendMessage "already in use" >> SendMessage1
2 : "lparam as any" >> "lparam as long"
3 : keybd_event + "Alias "keybd_event""
4 : sleep + "Alias "Sleep""
5 : "Optional DelayMS As Long = 0" error >> DelayMS As Long (??)
and other that I really don't know what to do.
6 : error "trying to assign reserved word BYTE" ??????

)o )O
Message4. Modified
Posted by: guidance 2002-12-22 09:24:31
I didn't verify it, sorry.
Modified a little bit and passed compile. I don't have enough time to make a full demo. Welcome & thanks if you made that finally and put onto upload directory:
Hope helpful!
Message5. Re: Modified
Posted by: 2002-12-22 23:26:37
Not bad...
I have launched it with lines added "SendKeyApi = 0", "ShowStartMenu", "End". It works but... the mouse and the keyboard give no responses for a while. After pressing a few keys I have take again the control of the keyboard. But it's a big problem...

And : where can I find the code for the "Alt" key (? vbKeyAlt). I have search on MSDN and not find it, except with visual wich have another syntax (closer c++ I think).
Message6. Re: Modified
Posted by: 2002-12-22 23:50:22
Here's a .exe Form with the same problem : no responding of the mouse of keyboard after the sendkeys. Pressing "Alt Gr" ends problem.

    Caption = "Rapid-Q SendKeys"
    Width = 200
    Height = 80
        Caption = "SendKeys : Ctrl + Esc"
        Left = 25
        Top = 10
        width = 150


'Insert your initialization code here

'Modified by Guidance ( 2002-12-22

'From:  "Gregg Morrison" <greggmor@b...> Date:  Sat Aug 31, 2002  5:24 am
' the API way to send keys to any window, so here it is:
'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 Declare Sub keybd_event Lib "user32" alias "keybd_event" (ByVal bVk As Byte, ByVal bScan _
As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
' This is cross-application SendKeys

'Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public Const KEYEVENTF_KEYUP = &H2 ' Release key
Public Const WM_SETFOCUS = &H7& ' &h0007
Public Const WM_KILLFOCUS = &H8& '&h0008

' set focus to any displayed window using hWnd = WindowHandle
SendMessage hWnd, WM_SETFOCUS, 0&, 0&

' Send a string of keys with optional keypress delay
' This simulates pressing an releasing each key in the Byte Array

Public Sub SendKeysAPI(bytKeystack() As Byte, _ 'Optional
DelayMS As Long)' = 0)
Dim nKeyCnt As Long

For nKeyCnt = LBound(bytKeystack) To UBound(bytKeystack)
keybd_event bytKeystack(nKeyCnt), 0, 0, 0 ' Simulate KeyPress
' let Windows Process Message
If DelayMS Then Sleep DelayMS ' Delay - 0, 5, 10 milliseconds if needed

' Simulate KeyRelease
keybd_event bytKeystack(nKeyCnt), 0, KEYEVENTF_KEYUP, 0
' Let Windows Process Message
Next nKeyCnt

End Sub

' Here is an example using control keys
defBYTE vbKeyControl = 17 ' CTRL key
defBYTE vbKeyEscape = 27 ' ESC key

Public Sub ShowStartMenu()

' Press the Ctrl-Esc key - Same as the 'Windows' key
keybd_event vbKeyControl, 0, 0, 0
keybd_event vbKeyEscape, 0, 0, 0

'Release the two keys
keybd_event vbKeyControl, 0, KEYEVENTF_KEYUP, 0
keybd_event vbKeyEscape, 0, KEYEVENTF_KEYUP, 0

End Sub

Sub Envoi()
SendKeyAPI = 0
End Sub

Button.OnMouseDown = Envoi
Message7. Another VB example
Posted by: guidance 2002-12-23 19:57:44
With keycode definition, may help:
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
© Tue 2024-7-23  Guidance Laboratory Inc. Hits:0