How do I Execute multi programs

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

How do I Execute multi programs

 
0
  #1
Jun 8th, 2006
How do i execute multi programs in at one time using maybe a batch file or something like that so that way they would be like embeded in the 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: How do I Execute multi programs

 
0
  #2
Jun 8th, 2006
I don't know exactly what you are talking about..... if you tell me what you want to accomplish I can help you out a little more.... a batch file is going to wait though, for 1 command to finish before moving on to the next. The shell command (or shellexecute) in VB will launch the app in question, and then move straight on to the next line of code (which could just as easily be another launch of an app).
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: How do I Execute multi programs

 
0
  #3
Jun 19th, 2006
Originally Posted by Comatose
I don't know exactly what you are talking about..... if you tell me what you want to accomplish I can help you out a little more.... a batch file is going to wait though, for 1 command to finish before moving on to the next. The shell command (or shellexecute) in VB will launch the app in question, and then move straight on to the next line of code (which could just as easily be another launch of an app).

I am tring To Get This program to install First remember what they specify on the SP page and in stall it at the end. Also i am tring to get the program to install the proper updates that are need for the Operating system selected and then install the antivirus or the Internet securities, with the updates copied from a specific folder and placed in a designated folder on the hard drive. I then need it to install the Spyweeper and its updates to the proper place on the Hd. BUT I NEED IT TO DO IT where no on can see it. It okay for it to show on the task bare but not on the screen its self.
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: How do I Execute multi programs

 
0
  #4
Jun 19th, 2006
Ouch, that's going to be tough, because most of the mechinisms required to directly affect another program require that program to have focus..... you can use SENDMESSAGE (the sendmessage api call) and try to send say WM_SETTEXT to the textbox in question, while leaving it in the background.... but finding the hWnd (Windows Handle) of the textbox in another program's thread is going to be real tough..... you can TRY findwindowex, (in conjunction with findwindow) but you are going to have a tough time with that.
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: How do I Execute multi programs

 
0
  #5
Jun 20th, 2006
Originally Posted by Comatose
Ouch, that's going to be tough, because most of the mechinisms required to directly affect another program require that program to have focus..... you can use SENDMESSAGE (the sendmessage api call) and try to send say WM_SETTEXT to the textbox in question, while leaving it in the background.... but finding the hWnd (Windows Handle) of the textbox in another program's thread is going to be real tough..... you can TRY findwindowex, (in conjunction with findwindow) but you are going to have a tough time with that.


Could You give Me a couple of examples of the send key and also what your talking bout here please
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: How do I Execute multi programs

 
0
  #6
Jun 20th, 2006
Sendkeys is a command in VB that allows you to send keystrokes from your app to the currently active (foreground) application. For example, you can open a blank notepad document, and send something to it like so:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Shell "c:\windows\notepad.exe", vbNormalFocus
  2. Me.Show
  3. DoEvents
  4. AppActivate ("Untitled - Notepad")
  5. SendKeys "hello world"

The problem, is that you need the window to stay behind your application, and therefore, sendkeys will not work.

Now, you can TRY to use the windows API.... which has certain function calls that might help.... one of those function calls is "sendmessage" which allows your program to send a windows message (a hex number that windows understands to do something). Everything that happens to a window, mouse move, mouse down, mouse up is done by a windows message. One of the windows messages, is called "WM_SETTEXT", which has some hex value... pretty nifty huh, WM for windows message, and settext for what it does....

Now, we've just increased our power significantly from sending keystrokes, to sending any kind of message that windows can send....(just about, this isn't the C language, so we have no power in pointers [except addressof, but not really the same]). This leads us to a major problem.... it's all find and dandy, but we have to know the hWnd to send this information to. Every window (mind you, everything in windows is a window.... a textbox, a listbox, a window, a button, they are all a window) every window has an hWnd. An hWnd is a number windows randomly assigns to a window (any window) to identify it from other windows. So, you are going to have to try to find the hwnd, not of the program, but of the textbox on the program, that you want to set the text of. Now, there is a way to do this, but it requires a lot of work, and a lot of trial and error. You need to use the "findwindow" API, AND the FindwindowEx API. The reason, is because the hWnd of any window changes every time. It's never the same. Every time the program launches, windows craps out a new hWnd. Nice huh?

Now, things get complicated. Windows are hierachial, so, each "control" which is a window, actually has a "parent" window. Meaning that a textbox, combo-box, listbox, button, etc, are all children windows that are owned by their parent window. So, that means, you'll have to first get the hWnd of the parent window. (oh yeah, and this is assuming the textboxes or whatever aren't in a frame, or some other container control which behaves as the temporary foster parent.... meaning, you'd have to get the main window's hWnd, then the Frame's hWnd, THEN the textbox's hWnd). Now, if the window has more than 1 textbox, you'll have to do findwindowex in a loop (findwindow returns the hWnd of a top level window, findwindowEx returns the hWnd of a child window of the parent hWnd specified), and figure out which order they get returned to your program, so you know which one you need to use to send the WM_SETTEXT message to.

I've attached the code for using SendMessage with the WM_SETTEXT constant, and I've also attached a program that will get the hWnd of whatever window is beneath the mouse. This way, so you can see what I"m talking about with the settext. If you run GetClass, it will return a wealth of information about whatever window is beneath the mouse cursor... the hwnd, the class, the title, and the threadID. Then if you run the settext program, and place the cursor over a textbox (with getclass running) and get the hwnd, plug that into the settext program, and type something, and hit set.... it will set the text in the textbox of a different program......
Attached Files
File Type: zip SetText.zip (48.5 KB, 31 views)
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