tags:

views:

383

answers:

1

Heres my code that does not work:

Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4

Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Dim wHandle As Long = FindWindow(vbNullString, "Ultima Online")

PostMessage(wHandle, MOUSEEVENTF_LEFTDOWN, 0, 0)
PostMessage(wHandle, MOUSEEVENTF_LEFTUP, 0, 0)
A: 

I'm not sure why this code should work - it seems you're just clicking on the window, not on a specific button.
To minimize windows you could use another api function: SetWindowPlacement, see: http://www.codeproject.com/KB/dialog/Minimizewindow.aspx

Another idea: If you want a hacky solution you can send the keys Alt+Space n to minimize a window, but this is very hacky, and works only for English machines:

SendKeys ("% n") ''//in vb6
SendKeys.Send("% n") ''//in vb.net
Kobi