Hi.
Im using Sendkeys to send keystrokes within my VB app. However, its not too reliable, and skips out on instances. Is there a more reliable, (free) alternate for Sendkeys that can be used in a VB6 app?
Thanks
Printable View
Hi.
Im using Sendkeys to send keystrokes within my VB app. However, its not too reliable, and skips out on instances. Is there a more reliable, (free) alternate for Sendkeys that can be used in a VB6 app?
Thanks
there is an API available for sending keystrokes...just google for that, you will get examples here in VBF
When using sendkeys, make the wait parameter to True and use Sleep() function to make it more reliable sort of putting a little delay before firing the next sendkeys.
Sample
this is some lame tricks if you dont want to use the API sendkeys.Code:Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
SendKeys "{F2}", True 'sending F2 keys and wait for the process to finish before firing the next sendkeys
Sleep 100
SendKeys "^{C}", True
'... etc etc
Most often the problems with Sendkeys are timing related (as zynder pointed out)
PS
MS has guaranteed that VB6 apps would run ok in Vista
But I am hearing that Sendkeys has problems, and MS does not give a sh....
So if some kind sole can post a complete alternative module, it would be great.
Why are you using SendKeys within your own program? What exactly are you doing with it?
SendKeys is the worst VB function ever made :lol:
Seriously, you can use the keybd_event API to simulate keypresses but it like SendKeys relies upon the receiving object to have the input focus.
SendMessage and PostMessage APIs are the most reliable and durable functions for sending keypresses or what not.
SendKeys does not work when trying to send keys to IE7.
Some sort of spammer i assume? Anyway i know for one in a "Storm.dll" there is a function which is ten times better than SendKeys but i forget what it was.
Agreed, Sendkeys is awful.
Especially if you are sending commands to your own program, it is not necessary.
Maybe its a language issue here. Probably the poster means to send key strokes from within his application to some other destination. ;)
I certainly hope so :|
Can we get the original poster to help us out and ease our blood pressure yet?
Original poster here.
Yes, i mucked up with the grammar there. Im trying to get my VB app to send keystrokes to another application. Basically, its a datafeed Im getting in the form of a bunch of invoices. What im trying to do is capture the prices of a certain object from the invoices, and send it to another application.
There may be other ways ot do it, but i want to use keystrokes, since that is quick in my case, and i will be needing the keystrokes in other areas of this app as well. So any alternate to sendkeys would be much appreciated.
Hi style, I recently used sendkeys to control another program from VB6. I got it to work reliably, but only after ZYNDER's suggestion posted above. Add that TRUE word at the end of your string (makes VB6 wait for other program to respond before sending next key) and put loads of sleep delays inbetween sets of keystrokes. I started with sellp 100's, but eventually was able to reduce to sleep 10's - but every program will tend to be different. Unless you are in a big hurry for this thing to work, the longer the delays the better has been my recent experience.
ca moore
But with scenerios like using SendKeys and even the keybd_event API you are tieing up your system as you can not disturb the active application.
If you use SendMessage/PostMessage you can have the automation running in the background while you can continue to work or post here at VBF :D
i agree with Rob u can use sendmessage or postmessage api
Thank you, noted by contributor ca Moore. I am, relative to you folk, a novice at VB but usually I find some waqy to overcome problems (with the help of forum!) albeit not the most elegant.
CAM