how to control another program that is running

T

Tee

Hi,

Does anyone know how to control another program that is running?

Eg: I would like to control the outlook express and tells it to minimize.

Thanks.
 
K

Ken Tucker [MVP]

Hi,

Use the process class to find outlook express (msimn is
process name) and use setwindowslong to minimize it. Here is an example.


Api declares and constants


Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _

(ByVal hwnd As IntPtr, ByVal nIndex As Integer, _

ByVal dwNewLong As Integer) As Integer



Const WS_MINIMIZE As Integer = &H20000000

Const GWL_STYLE As Integer = (-16)



How to find and minimize



For Each p As Process In Process.GetProcessesByName("msimn")

SetWindowLong(p.MainWindowHandle, GWL_STYLE, WS_MINIMIZE)

Next



Ken

-----------------------

Hi,

Does anyone know how to control another program that is running?

Eg: I would like to control the outlook express and tells it to minimize.

Thanks.
 
H

Herfried K. Wagner [MVP]

Tee said:
Does anyone know how to control another program that is running?

Eg: I would like to control the outlook express and tells it to minimize.

\\\
Private Declare Function ShowWindow Lib "user32.dll" ( _
ByVal hwnd As IntPtr, _
ByVal nCmdShow As Int32 _
) As Int32

Private Const SW_MINIMIZE As Int32 = 6
..
..
..
ShowWindow(p.MainWindowHandle, SW_MINIMIZE)
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top