944,209 Members | Top Members by Rank

Ad:
May 12th, 2006
0

Make It Select Different Things

Expand Post »
How Do I make Visual basic click on other icons in other programs. Like The next and finish and Install cmd buttons. Is it possible to copy text out of a text out of text boxes and Enter them into a program. Kinda Like COPY AND PASTE
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Smooth_411_2000 is offline Offline
25 posts
since Apr 2006
May 12th, 2006
0

Re: Make It Select Different Things

You'll want to look into the "sendkeys" command. This command allows you to send keystrokes to applications (shift-end, ctrl-c, ctrl-v). Keep in mind, sendkeys only sends keystrokes to the currently active (foreground) window. So, you'll want to make whatever window you want to mess with the foreground first, with either appactivate, or the setforegroundwindow (and setactivewindow) api calls. If you want to get more complicated than that (say, cross-task subclassing) you are going to want to be very... very careful.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
May 13th, 2006
0

Re: Make It Select Different Things

Quote originally posted by Comatose ...
You'll want to look into the "sendkeys" command. This command allows you to send keystrokes to applications (shift-end, ctrl-c, ctrl-v). Keep in mind, sendkeys only sends keystrokes to the currently active (foreground) window. So, you'll want to make whatever window you want to mess with the foreground first, with either appactivate, or the setforegroundwindow (and setactivewindow) api calls. If you want to get more complicated than that (say, cross-task subclassing) you are going to want to be very... very careful.
How would i use the send keys in my program
Reputation Points: 10
Solved Threads: 0
Light Poster
Smooth_411_2000 is offline Offline
25 posts
since Apr 2006
May 13th, 2006
0

Re: Make It Select Different Things

Sendkeys is usually not a great idea.... because there are a ton of problems that can occur. What if the user switches focus (or what if there is spyware or some other junk that spawns new windows for the hell of it), while your program is in the midst of sending keys..... all hell can break loose. Read up on this thread, and check out this page: http://www.daniweb.com/techtalkforums/post127770.html
http://www.scriptlogic.com/Kixtart/h...s/sendkeys.htm
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub Form_Load()
  2. Shell "c:\windows\notepad.exe", vbNormalFocus
  3. Me.Show
  4. AppActivate "Untitled - Notepad"
  5. SendKeys "This Is A Test!"
  6. SendKeys "+{HOME}"
  7. End Sub
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
May 30th, 2006
0

Re: Make It Select Different Things

Quote originally posted by Comatose ...
Sendkeys is usually not a great idea.... because there are a ton of problems that can occur. What if the user switches focus (or what if there is spyware or some other junk that spawns new windows for the hell of it), while your program is in the midst of sending keys..... all hell can break loose. Read up on this thread, and check out this page: http://www.daniweb.com/techtalkforums/post127770.html
http://www.scriptlogic.com/Kixtart/h...s/sendkeys.htm
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub Form_Load()
  2. Shell "c:\windows\notepad.exe", vbNormalFocus
  3. Me.Show
  4. AppActivate "Untitled - Notepad"
  5. SendKeys "This Is A Test!"
  6. SendKeys "+{HOME}"
  7. End Sub

If Send Keys are a bad idea, what you you do to click on the buttons that need to be clicked in this program.
Reputation Points: 10
Solved Threads: 0
Light Poster
Smooth_411_2000 is offline Offline
25 posts
since Apr 2006
May 30th, 2006
0

Re: Make It Select Different Things

Well, generally it's a poor idea to try to automate a program that isn't made to be automated. Excel for example, let's you create an object in it's name, and work with it's properties and methods. Trying to force yourself on a program that doesn't expect it, can lead to crappy results. That's all I'm saying.... sendkeys may well be your only option, unless you dig into something like findwindow, and findwindowEX api calls, and then use the sendmessage API.... but findwindow and findwindowex can produce some flakey results when trying to find a specific child window...... stick with sendkeys, but just know that what you are doing is Taboo.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: To check files
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: tabledef in ado





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC