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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I use VB to enter keystrokes into another application?

Status
Not open for further replies.

Blitz

Technical User
Jul 7, 2000
171
US
I dont know VB and am trying to find out if I should spend the time to learn it. I need to be able to write a program that will enter keystokes into another program (basically running through a sequence of F1 F1 F6 1 F1 in the other program), if I can Ill spend the time to learn VB. <br><br>If it can be done could someone please give me a basic overview of how to do it? Thanks.
 
You can do that with:<br><FONT FACE=monospace><br>SendKeys &quot;{F1}{F1}{F6}1{F1}&quot;, True<br></font><br>The &quot;True&quot; flag at the end makes sure that the keys are processed before control is returned. The &quot;Fn&quot;s in brackets are VB's way of sending the various function keys to the currently open window. Which raises an interesting point... VB can only send keystrokes to the window with focus. If your app has the focus, the keystrokes will end up there. You will have to hide the current form to prevent it from receiving the keys, and then restore it to a normal window.<br><br>A second point (or question, if you will) is why do you need to manipulate the functions of another application? If you are trying to learn VB, the answer to that question will become apparent shortly. If you are trying to manipulate another app without a good reason, without an understanding, you will still get an answer.<br><br>But the results may not be as you expected.<br><br>Take care!<br> <p> <br><a href=mailto: > </a><br><a href= plain black box</a><br>
 
Well the reason I need to do this is because our companys accounting software is bad. Every week I have to run through the sequence F1 F1 F6 1 F1, F1 F1 F6 2 F1, etc. for over 150 of the propertys we manage. And the reason I need to use the keystrokes is that its a Unix program running in a Windows window, no Windows controls etc.<br><br>So if you know of a better way to do this let me know.
 
Now I understand. I have had to do something similar with scripts written in an ancient (pre-DOS 4) version of Paradox. It's a royal pain.<br><br>One of the problems with the old apps is that they may ignore (fail to receive) the keystrokes sent by another app. Post back if the SendKeys function doesn't work and we'll start thinking about a different solution. <p> <br><a href=mailto: > </a><br><a href= plain black box</a><br>
 
Well I wrote the program last night and it worked fine :)&nbsp;&nbsp;VB is alot easier to learn than I could have imagined. I made a access database of our building #'s so the program loops for every record in the databse taking the building # field and using the sendkeys to send it to the other program. I dont have the code on this computer but I may post it on here tomorrow to see if you guys can see anything you thing could be wrong/improved.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top