Make It Select Different Things

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Apr 2006
Posts: 25
Reputation: Smooth_411_2000 is an unknown quantity at this point 
Solved Threads: 0
Smooth_411_2000 Smooth_411_2000 is offline Offline
Light Poster

Make It Select Different Things

 
0
  #1
May 12th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Make It Select Different Things

 
0
  #2
May 12th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 25
Reputation: Smooth_411_2000 is an unknown quantity at this point 
Solved Threads: 0
Smooth_411_2000 Smooth_411_2000 is offline Offline
Light Poster

Re: Make It Select Different Things

 
0
  #3
May 13th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Make It Select Different Things

 
0
  #4
May 13th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 25
Reputation: Smooth_411_2000 is an unknown quantity at this point 
Solved Threads: 0
Smooth_411_2000 Smooth_411_2000 is offline Offline
Light Poster

Re: Make It Select Different Things

 
0
  #5
May 30th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Make It Select Different Things

 
0
  #6
May 30th, 2006
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC