Visual Basic 2008 Express Bring running process to teh front


If i have several applications running, eg calc, outlook, word, etc

Id like to know a way to go about creating a script in VB where the scriot will look for the calc process and bring the calc window to the front.

Any help will be greatly appreciated.

If you require more information please let me know


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dennis AriesCEO @ Arkro ITCommented:
Seems to me like you'll be wanting to use the 'FindWindowEx'-API-call in conjuction with the 'SetForeGroundWindow'-api

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dennis AriesCEO @ Arkro ITCommented:
And now with code :)
Seems to me like you'll be wanting to use the 'FindWindowEx'-API-call in conjuction with the 'SetForeGroundWindow'-api

<DllImport("user32.dll", EntryPoint:="SetForegroundWindow")> _
Shared Function SetForegroundWindow(ByVal hwnd As IntPtr) As Integer
    End Function
    <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    Private Shared Function FindWindow( _
         ByVal lpClassName As String, _
         ByVal lpWindowName As String) As IntPtr
    End Function

    Private Sub ActivateCalc()
        Dim hWnd As IntPtr = FindWindow(vbNullString, "Calculator")
        If (hWnd <> IntPtr.Zero) Then
        End If
    End Sub

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.