Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Animate application with sendkeys

Status
Not open for further replies.

Glasgow

IS-IT--Management
Jul 30, 2001
1,669
0
0
GB
I am trying to use Sendkeys to automate my application but in a way whereby it is visible to the user what is happening. I can do this using Sendkeys but it all happens to fast and all my attempts to implement delays have been unsuccessful.

As an example, I'd like to send the Alt key (SendKeys "%")alone to activate the MDIForm's drop down menu bar then move along two menus (SendKeys "{RIGHT}" x 2) then down three options on the menu (SendKeys "{DOWN}" x 3) then select that option (SendKeys "{ENTER}"). All at a speed that the user can see each movement (e.g. half a second between each movement.

I have tried using the sendkeys wait parameter, Doevents plus enforced delays (using Sleep API call) all to no avail.

Any suggesions?

Thanks in advance.
 
Thanks for further input.

Greggie I had already tried doing the send character by character (no joy).

LPent Interesting but I'm not sure how I'd apply such a resolution in practice as I don't want lots of user intervention to be required. Also, if you are doing this on the basis of button click events, won't the initial Sendkeys "%E" be 'lost' as you move focus to the button to trigger the {DOWN}s. I have tried putting keys into a string that is processed (and reduced) in a timer event but this doesn't seem to work either.

Unfortunately I am limited as to the time I can devote to this particular problem at the moment but I'd ultimately still like to resolve it.
 
Hi Glasgow,

Yes, the "%E" will in general get lost because the problem with this is that you can't have the user move the mouse or type something on the keyboard. As soon is this happens the "buffer" will "unwind"/be cleared.
However; in the example above, the Click_Event is triggered by the sendkeys-command itself, so here it won't get "lost" (%E opens the "Edit"-menu which triggers the Click_Event on this menu). The problem is how you would trigger an event from those {DOWN} keys (probably a form_keydown event with the keypreview of the form set to true? I haven't tried this).
A timer event won't work because of the same problem as stated above (same event).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top