+ Reply to Thread
Results 1 to 3 of 3

Close an application with sendkeys

  1. #1
    ina
    Guest

    Close an application with sendkeys

    Hello,

    This is my code to open my program from excel;

    Public Sub OpenPLaunchShell()
    On Error GoTo Err_PLaunch

    Dim strappPack As String
    Dim BoPack As Boolean


    On Error Resume Next

    strappPack = "C:\Program Files\PLaunch\PLaunch.exe"



    If Err <> 0 Then


    BoPack = True ' if no error PLaunch is open
    Err.Clear
    MsgBox "PLaunch is not open"
    Call Shell(strappPack, 2)
    AppActivate strappPack
    Exit Sub

    Else
    Exit Sub
    MsgBox "Found PLaunch open"
    End If

    'Exit from the code
    ExitCode:
    Exit Sub

    'Error Handler
    Err_PLaunch:
    MsgBox Err.Description
    Resume ExitCode


    End Sub


    This is the sub to close my program; but the problem is that I close
    the visual studio when I try to execute this code:


    Sub ClosePLaunch()


    Dim strappPack As String

    strappPack = "C:\Program Files\PLaunch\PLaunch.exe"


    'Close PLaunch
    SendKeys "%{F4}", True
    DoEvents

    End Sub

    Someone has any suggestion how to close an application on sending the
    Alt+F4 key.

    Ina


  2. #2
    AA2e72E
    Guest

    RE: Close an application with sendkeys

    If you know the Windows Handle of your application (Use the FindWindow API),
    you can close it using the SendMessage or PostMessage API call.

  3. #3
    ina
    Guest

    Re: Close an application with sendkeys

    Thank you I used the createobject and now it is fine. but the program
    open twice and I do not know why

    Ina


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1