Results 1 to 7 of 7

Thread: interacting with applications

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Posts
    88

    Post

    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

  2. #2
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    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

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    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!"

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Posts
    88

    Post

    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?

  5. #5
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408

    Post

    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]


  6. #6
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    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

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Posts
    88

    Post

    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
  •  



Click Here to Expand Forum to Full Width