Guidance
指路人
g.yi.org
Guidance Forums / Rapid-Q Basic / VB sendkeys

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. VB sendkeys
#711
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
#712
Posted by: guidance 2002-12-21 07:10:05
RQ sendkeys example (by win32 api):
http://g.slyip.com/_scripts/file.php?f=2677&r=2330

By the way, you may try the in-site search here by press alt-s, enjoy :)
Message3. Re: RQ sendkeys
#713
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
#714
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: http://g.slyip.com/_scripts/file.php?f=2677&r=2330
Hope helpful!
Message5. Re: Modified
#715
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 basic.net wich have another syntax (closer c++ I think).
Message6. Re: Modified
#716
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.

CREATE Form AS QFORM
    Caption = "Rapid-Q SendKeys"
    Width = 200
    Height = 80
    Center
    CREATE Button AS QBUTTON
        Caption = "SendKeys : Ctrl + Esc"
        Left = 25
        Top = 10
        width = 150
    END CREATE

END CREATE

'Insert your initialization code here

'Modified by Guidance (http://citymap.126.com) 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
'bytKetStack()

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
DoEvents
' 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
DoEvents
' 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
DoEvents

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

End Sub

Sub Envoi()
SendKeyAPI = 0
ShowStartMenu
End Sub

Button.OnMouseDown = Envoi
Form.ShowModal
Message7. Another VB example
#717
Posted by: guidance 2002-12-23 19:57:44
With keycode definition, may help:
http://g.slyip.com/_scripts/file.php?f=2699&r=2330
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
¥738.00 ·
 
 
¥1,480.00 ·
 
 
¥397.00 ·
 
 
¥950.00 ·
 
 
¥264.00 ·
 
 
¥1,005.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0