Results 1 to 10 of 10

Thread: Closing application

  1. #1

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Closing application

    Hi ,
    I want to close an application with postmessage. For word it is working fine. But the Software I am using is ultraedit is opening text with the new tab only. In this i am facing problem getting the handle by its caption.
    Because the application may contain any number text documents.
    Can some body help me

  2. #2
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Closing application

    post the code u are using to close apps...
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Closing application

    extention1 ="UltraEdit-32 - [" & "C:\test1.txt"
    hWindow = FindWindow(vbNullString, extention1)
    lngReturnValue = PostMessage(hWindow, WM_CLOSE, vbNull, vbNull)

    The problem here is that if the user changes the tab in the application window I am not abled to get the window handle.

    Is is there any method to find the instance of an application and close it

  4. #4
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Closing application

    Using SPY++ find the class name of the Applicationa and then use the classname rather than the windowtext to get the window handle.

    Spy ++ can be found under Start/Programs/Microsoft Visual Studio 6.0/Microsoft Visual Studio 6.0 tools.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  5. #5

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Closing application

    Please Explain me, I could not able to get u

  6. #6
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Closing application

    FindWindow API accepts two parameters.

    1. The classname
    2. The text in the caption of the window.

    Now if you are not sure about the caption (you are saying that it might change) so you will be better of using the ClassName. To get the classname of the specified window read my previous post.

    Your code for Findwindow will change to this after you know the classname
    VB Code:
    1. hWindow = FindWindow(className, vbNullString)
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  7. #7
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Closing application

    hmm.. well I just tried a bunch of ways.. didnt work.. sorry.

    I will keep trying
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  8. #8

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Closing application

    Can y post me the link

  9. #9
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Closing application

    Quote Originally Posted by danasegarane
    Can y post me the link
    Link to what?
    Have you tried what I suggested?
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Re: Closing application

    These should help you.

    Find window by partial caption:
    http://vbforums.com/showthread.php?t=316924

    Spy++ clone:

    http://vbforums.com/showthread.php?t=337952
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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