VB Code:
Option Explicit
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Command1_Click()
Shell "C:\winnt\system32\calc.exe", vbNormalFocus
End Sub
Private Sub Command2_Click()
Dim hwnd&, width&, height&
Dim R As RECT
hwnd = FindWindow("scicalc", vbNullString)
GetWindowRect hwnd, R
width = R.Right - R.Left
height = R.Bottom - R.Top
'center on screen
MoveWindow hwnd, Screen.width / Screen.TwipsPerPixelX / 2 - width / 2, Screen.height / Screen.TwipsPerPixelY / 2 - height / 2, width, height, 1
End Sub