1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

run a program

Discussion in 'Visual Basic 6' started by mylikes786, Jan 30, 2014.

  1. mylikes786

    mylikes786 Registered Member

    Joined:
    Oct 31, 2013
    Messages:
    80
    Likes Received:
    6
    I want run a program
    and once the program is the run i want it automtically click enter key

    How can i do that?
     
  2. bartosimpsonio

    bartosimpsonio Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 21, 2013
    Messages:
    8,912
    Likes Received:
    7,495
    Occupation:
    ZLinky2Buy SEO Services
    Location:
    ⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩
    Home Page:
    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.
     
  3. Numbuh362

    Numbuh362 Elite Member

    Joined:
    Aug 22, 2012
    Messages:
    1,569
    Likes Received:
    462
    code it to press the enter key. idk what else to say, make sure to add a me.close() ;)
     
  4. TehEpidemick

    TehEpidemick BANNED BANNED

    Joined:
    Oct 31, 2011
    Messages:
    778
    Likes Received:
    181
    lol....very weird program sir
     
  5. mandingo

    mandingo Newbie

    Joined:
    Jan 29, 2014
    Messages:
    10
    Likes Received:
    2
    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.
     
  6. inaga

    inaga Newbie

    Joined:
    Feb 4, 2010
    Messages:
    12
    Likes Received:
    3
    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!
     
  7. wolverine

    wolverine Newbie

    Joined:
    Jul 7, 2008
    Messages:
    14
    Likes Received:
    0
    Are you trying to invoke the enter key inside your own program or do you want to invoke it for a different program?