|
-
Feb 15th, 2000, 04:44 AM
#1
Thread Starter
Lively Member
i'm attempting to write a simple application/control that will allow me to void several thousand transactions that are contained within a foxpro program that was written for my company. the process of voiding a transaction involves hitting two "yes" buttons, an "ok" button, and a movenext button. all of these things can be done from the keyboard. it seemed easy enough at first until i tried to tell visual basic to hit "CTRL-V". there is plenty of documentation on how to react to a keypress or a keydown/keyup event, but nothing on how to force one. does anyone have any suggestions?
darrell hawley
-
Feb 15th, 2000, 05:02 AM
#2
Hyperactive Member
If there's no need to be concerned that a user might select a different window or select a key while keys are being sent to your app, you can use SendKeys.
Shell to the app and then use Sendkeys.
If you are concerned that the user might select another window while your app is running or that they might hit keys, you'll have to use the API.
Wade
-
Feb 15th, 2000, 05:06 AM
#3
Look in help for SendKeys. I think this will do it:
SendKeys "^V"
------------------
Marty
What did the fish say when it hit the concrete wall?
> > > > > "Dam!"
-
Feb 15th, 2000, 06:47 AM
#4
Thread Starter
Lively Member
thanks for the help, guys. the sendkeys method was exactly what i needed. however, is there a way of delaying the next line of code for x number of seconds or milliseconds to allow the attached program to catch-up?
-
Feb 15th, 2000, 06:57 AM
#5
Hyperactive Member
put this in your module:
Sub Timeout(duration)
StartTime = Timer
Do While Timer - StartTime < duration: DoEvents
Loop
End Sub
then whenever you need a "pause" in the code just put
timeout(your number)
example timeout(4)
umm i have not been able to get code to work if option explicit is in my code. So to use this take it out. Or ask someone else how to do it.
------------------
Sincerely,
Chris
:-) ;-)
just have fun out there and live life to the fullest while it is still here
Email [email protected]
-
Feb 15th, 2000, 07:23 AM
#6
Hyperactive Member
Darrell,
There's a second argument - the Wait argument indicating whether your app should wait for the keys to be processed before continuing. The default is False if you don't supply the argument. Say you were sending Alt+F, you would send:
SendKeys "(%f)", True
Wade
-
Feb 15th, 2000, 10:04 PM
#7
Thread Starter
Lively Member
thank you everyone for your help. i'm not only using this sendkeys thing for the current project, but i have another program that it really will be a big help on as well. thanks again.
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
|