Question PostMessage interrupts

xinchao

New member
Joined
Jul 12, 2010
Messages
2
Programming Experience
Beginner
Hello,

My application watches two buttons:

1. F11 => my application minimizes and hides another window (windowHandle is its handle), then sends there WM_RBUTTONDOWN (right mouse button click&hold).
2. F12 => my application unhides and restores that window, then sends WM_RBUTTONUP (right mouse button release).

The problem is when I press F11, and then click somewhere (so windowHandle loses focus), the right mouse button releases automatically, but I want it could be released only after I press F12. Here is part of my code:
VB.NET:
  Public Sub Tick()
    Dim windowHandle As IntPtr = FindWindow(vbNullString, "App")
    If GetAsyncKeyState(Keys.F11) Then
      ShowWindow(windowHandle, 6) 'Minimize
      ShowWindow(windowHandle, 0) 'Hide
      PostMessage(windowHandle, &H204, 0, 0) 'RButton press
    ElseIf GetAsyncKeyState(Keys.F12) Then
      ShowWindow(windowHandle, 5) 'Show
      ShowWindow(windowHandle, 9) 'Restore
      PostMessage(windowHandle, &H205, 0, 0) 'RButton release
    End If
  End Sub

So, is there any way how to not release right mouse button?

Thanks for your time.
 
Back
Top