|
-
Jan 7th, 2009, 03:49 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Help how to simulate sendkeys in Vista?
I've been using this code for ages in triggering TAB in VB6 using XP as my OS.
sendkeys Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
SendKeys vbTab
End If
End Sub
I'm using Vista Business now as my OS and I'm having error problems with the code above. Is there a way to to use the code above in vista? or can you suggest an API that I can use for vista? Any help is greatly appreciated.
-
Jan 7th, 2009, 08:05 AM
#2
Re: Help how to simulate sendkeys in Vista?
SendKeys isnt supported in Vista. You can use the SendMessage or PostMessage aPIs to replicate the message.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 7th, 2009, 09:25 AM
#3
Thread Starter
Addicted Member
Re: Help how to simulate sendkeys in Vista?
tnx for the reply. can you point me to a link for a sample code? tnx.
-
Jan 7th, 2009, 10:53 AM
#4
Addicted Member
Re: Help how to simulate sendkeys in Vista?
You need to use the keybd API
Code:
'Declares to include
Private Const VK_TAB = &H9
Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)
'heres the command to call
keybd_event VK_TAB, 0, 0, 0 'send a tab
-
Jan 7th, 2009, 01:56 PM
#5
Re: Help how to simulate sendkeys in Vista?
keybd_event requires input focus same as sendkeys but for the most stable method, see the APIs listed at http://allapi.mentalis.org.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 7th, 2009, 03:07 PM
#6
Re: Help how to simulate sendkeys in Vista?
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Jan 7th, 2009, 08:12 PM
#7
Fanatic Member
Re: Help how to simulate sendkeys in Vista?
thank you RobDog888 the api guild there is a big help
 Originally Posted by RobDog888
keybd_event requires input focus same as sendkeys but for the most stable method, see the APIs listed at http://allapi.mentalis.org.
Live life to the fullest!!
-
Jan 9th, 2009, 04:51 AM
#8
Thread Starter
Addicted Member
Re: Help how to simulate sendkeys in Vista?
I found this code here in vbforums. Works great.
Save the code below to a module
Module Code:
Option Explicit
Private Const KEYEVENTF_KEYUP = &H2
Private Const INPUT_KEYBOARD = 1
Private Type KEYBDINPUT
wVk As Integer
wScan As Integer
dwFlags As Long
time As Long
dwExtraInfo As Long
End Type
Private Type GENERALINPUT
dwType As Long
xi(0 To 23) As Byte
End Type
Private Declare Function SendInput Lib "user32.dll" (ByVal nInputs As Long, pInputs As GENERALINPUT, ByVal cbSize As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
Public Function SendKeysA(ByVal vKey As Integer, Optional booDown As Boolean = False)
Dim GInput(0) As GENERALINPUT
Dim KInput As KEYBDINPUT
KInput.wVk = vKey
If Not booDown Then
KInput.dwFlags = KEYEVENTF_KEYUP
End If
GInput(0).dwType = INPUT_KEYBOARD
CopyMemory GInput(0).xi(0), KInput, Len(KInput)
Call SendInput(1, GInput(0), Len(GInput(0)))
End Function
Then put this code to a form. Be sure the KEY PREVIEW of the form is set to TRUE
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|