• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 497
  • Last Modified:

Visual Basic 2008 Express Bring running process to teh front

Scenerio:

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

Regards

Liam
0
liamrichards
Asked:
liamrichards
  • 2
2 Solutions
 
Dennis AriesCEO @ Arkro ITCommented:
Seems to me like you'll be wanting to use the 'FindWindowEx'-API-call in conjuction with the 'SetForeGroundWindow'-api
 
 
0
 
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
            SetForegroundWindow(hWnd)
        End If
    End Sub

Open in new window

0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

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