run a program

mylikes786

Registered Member
Joined
Oct 31, 2013
Messages
81
Reaction score
7
I want run a program
and once the program is the run i want it automtically click enter key

How can i do that?
 
A program can only "click enter key" in itself, not on other programs.

To run a program in VB just bang your keyboard hard, eventually you'll hit the PLAY key shortcut.
 
code it to press the enter key. idk what else to say, make sure to add a me.close() ;)
 
Please be more clear in what you're trying to do.

If you are trying to press a button in your own program, you can call the command button's Click function.

If you are trying to press a button in another program, you will have to use something like SendKeys.

Or, the better way, use the Windows API functions like FindWindow to find the handle of the parent windows until you get the handle of the button. Then you can use something like SendMessage with the correct command (WM_LBUTTONDOWN and then WM_LBUTTONUP)

To run the program initially, you can use Shell, ShellExecute, or ShellExecuteEx depending on your needs.
 
I am taking a wild guess at exactly what you are trying to do. I think you want to execute a program and have a key pressed while it is in focus. The simplest way I know how using MSDN's example is as follows:

Code:
Dim notepadID As Integer
notepadID = Shell("c:\windows\system32\notepad.exe", vbNormalFocus)
AppActivate (notepadID)
SendKeys "{ENTER}", True

Hope this is what you are looking for!
 
Are you trying to invoke the enter key inside your own program or do you want to invoke it for a different program?
 
Back
Top