Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1018
  • Last Modified:

VB.net : FindWindowLike function to see if OUTlook is open

I have this:
 OutlookHwnd = FindWindow(vbNullString, "Microsoft Outlook").  
 SetActiveWindow(OutlookHwnd)
            Putfocus(OutlookHwnd)
            SetForegroundWindow(OutlookHwnd)


Outlook's title changes depending on what is selected....
How can I use FindWindowLike to see if OUtlook is open then bring it to the front
0
TechMonster
Asked:
TechMonster
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Do it this way instead...

        Dim Outlook() As Process = Process.GetProcessesByName("Outlook")
        If Outlook.Length > 0 Then
            ' Just FYI, you can get the main window caption using "MainWindowTitle"...
            Debug.Print(Outlook(0).MainWindowTitle) ' <--- this is the current title

            ' ...but use "MainWindowHandle" to get the window handle
            SetActiveWindow(Outlook(0).MainWindowHandle)
            Putfocus(Outlook(0).MainWindowHandle)
            SetForegroundWindow(Outlook(0).MainWindowHandle)
        End If
0
 
TechMonsterAuthor Commented:
That is far better than what I had before!  

Seems like an easier way than the Findwindowlike function,


Thanks a bunch!  You are truely a Genius!!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now