Wait for mouse button to be released
Moderators: JRL, Dorian (MJT support)
Wait for mouse button to be released
I know how to use WaitKeyDown>VK1 but is there a way to determine when it has been released?
Re: Wait for mouse button to be released
Here is one way to capture mouse button release. I think there is a Microsoft API that I've tried but this usually works and is something I can remember. Basically, make a transparent dialog that covers the screen. And use the built in "MouseUp" dialog event handler. In this example I placed the dialog at 0,0 and made the dialog size 10,000 x 10,000 pixels which is way larger than my screen area so it covers everything. You are likely aware of smarter ways to acquire total screen area then make the dialog that exact size.
If you need to use the mouse click on the underlying screen you'll need to capture the coordinates and use them after the dialog has closed. Usually you'll want the mouse position when the mouse is clicked as well. That can be easily captured using a "MouseDown" dialog event handler.
Be sure you close the dialog or you lose your screen to it. If you forget, not a big problem, you can always close the dialog by clicking on it then pressing ALT + F4
If you need to use the mouse click on the underlying screen you'll need to capture the coordinates and use them after the dialog has closed. Usually you'll want the mouse position when the mouse is clicked as well. That can be easily captured using a "MouseDown" dialog event handler.
Be sure you close the dialog or you lose your screen to it. If you forget, not a big problem, you can always close the dialog by clicking on it then pressing ALT + F4
Code: Select all
Dialog>Dialog1
object Dialog1: TForm
Color = 16711808
BorderStyle = bsNone
TransparentColor = True
TransparentColorValue = 16711808
end
EndDialog>Dialog1
AddDialogHandler>Dialog1,,OnMouseUp,MouseUp
Let>WIN_USEHANDLE=1
MoveWindow>Dialog1.handle,0,0
ResizeWindow>Dialog1.handle,10000,10000
Let>WIN_USEHANDLE=0
Show>dialog1,
SRT>MouseUp
CloseDialog>Dialog1
MDL>mouse is released%crlf%Screen is unblocked
END>MouseUp
Re: Wait for mouse button to be released
Thanks I'll give it a try.