Results 1 to 14 of 14

Thread: Application Open?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2004
    Posts
    908

    Application Open?

    HOw do i check if a certain application has open? (particularly lotus note)
    Last edited by Goh; May 10th, 2004 at 07:24 PM.

  2. #2
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    4.  
    5. Private Sub Command1_Click()
    6. Dim lngHandle As Long
    7.    lngHandle = FindWindow(vbNullstring, "Lotus Notes")
    8.    If lngHandle > 0 Then
    9.       MsgBox "Lotus is running"
    10.    End If
    11. End Sub
    The "Lotus Notes" part is the CAPTION of the Lotus Window.
    When replying to this thread my IE caption changes to "VBForums.com - Reply to Topic - Microsoft Internet Explorer".

    Woka

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2004
    Posts
    908
    i have replace the "lotus note" with excel...



    Option Explicit

    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

    Private Sub Command1_Click()
    Dim lngHandle As Long
    lngHandle = FindWindow(vbNullString, "Microsoft Office Excel 2003")
    If lngHandle > 0 Then
    MsgBox "Lotus is running"
    End If
    End Sub

    but it wont work.....


    "The "Lotus Notes" part is the CAPTION of the Lotus Window.
    When replying to this thread my IE caption changes to "VBForums.com - Reply to Topic - Microsoft Internet Explorer"." dun really understand this part..

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    Are you sure that is the right caption?

    I get: "Microsoft Excel - filename.xls"

    or just: "Microsoft Excel"

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2004
    Posts
    908
    how do i check the caption of an application?

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2004
    Posts
    908
    i got it thanks!

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    you look at the top bar of the Window
    Attached Images Attached Images  

  8. #8

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2004
    Posts
    908
    yes thank you....btw...does this code works on all applicaiton?

  10. #10
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    Try it and find out

    to the code add:
    VB Code:
    1. Private Declare Function DestroyWindow Lib "user32" Alias "DestroyWindow" (ByVal hwnd As Long) As Long
    2.  
    3. 'then in the sub add
    4. If lngHandle > 0 Then
    5.    DestroyWindow lngHandle
    6. End If



    Woka

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2004
    Posts
    908
    wat is the actual effect to this code? to ensure that all application is checked?

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2004
    Posts
    908
    i have added the code but it would not kill the app...

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    4. Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
    5.  
    6.  
    7.  
    8. Private Sub Command1_Click()
    9. Dim lngHandle As Long
    10.    lngHandle = FindWindow(vbNullString, "Microsoft Excel - Book1")
    11.    If lngHandle > 0 Then
    12.       MsgBox "Lotus is running"
    13.    End If
    14.    'then in the sub add
    15. If lngHandle > 0 Then
    16.    DestroyWindow lngHandle
    17. End If
    18. End Sub
    Last edited by Goh; Apr 14th, 2004 at 10:35 AM.

  13. #13
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    Originally posted by Goh
    i have added the code but it would kill the app...

    ...DestroyWindow..
    you are surprised by that?



  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2004
    Posts
    908
    is it possible to detect the application running with a single set of codes, because all i wanted is make sure that the application is activated before the mail can be sent.....there are so many captions for lotus notes.... does it mean i have to write all?! thank you.. furher more this application can be used by mutli-users ie ...the captions varies from user to user!
    Last edited by Goh; May 10th, 2004 at 07:26 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width