I am trying to use the SendKeys()
command to another window with my VB6 app.
What I wanted is to click a button, and then have 10 seconds to go to the o
You can use this code in Module
Public Sub SendKeyTab(CForm As Form)
On Error Resume Next
Dim G As Single
For G = 0 To CForm .Controls.Count - 1
If CForm .Controls(G).TabIndex = CForm .ActiveControl.TabIndex + 1 Then CForm .Controls(G).SetFocus
Next
End Sub
On Each Form Level
If KeyCode
the problem is about vb6 IDE and windows desktop context menu and you will do as described in here :
http://www.vbforums.com/showthread.php?747425-SendKeys-and-Windows-8
and main reference is here :
http://www.vbforums.com/showthread.php?745925-RESOLVED-How-to-trigger-the-desktop-context-menu
For Windows 7: Change the UAC settings to never notify.
For Windows 8 and 10:
Add this method to any module:
Public Sub Sendkeys(text as variant, Optional wait As Boolean = False)
Dim WshShell As Object
Set WshShell = CreateObject("wscript.shell")
WshShell.Sendkeys cstr(text), wait
Set WshShell = Nothing
End Sub
It's worked fine for me in windows 10.
In a public Module add:
Public Sub Sendkeys(text$, Optional wait As Boolean = False)
Dim WshShell As Object
Set WshShell = CreateObject("wscript.shell")
WshShell.Sendkeys text, wait
Set WshShell = Nothing
End Sub
This will "overwrite" SendKeys Function
Use this API:
Public Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
and
keybd_event keycode, 0, 0, 0 'KEY DOWN
keybd_event keycode, 0, KEYEVENTF_KEYUP, 0 'KEY UP
when key code is 32 for space, 35 for keyend, 8 for vbKeyBack, etc.
Replacement for VB6 SendKeys is WScript.Shell SendKeys, like this:
Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "1{+}"
See MSDN for help.