C#C
C#3y ago
Cience

✅ Detect holding mouse from in and outside the form

this here https://stackoverflow.com/questions/49068445/c-sharp-detect-mouse-clicks-anywhere-inside-and-outside-the-form
is the general concept but it only works on singular mouse clicks, here is a base example
and if the mouse button is released the code stops i cant really explain stuff well so if you need to know more please ask

using WPF, Visual studio 2022.

```csharp
if(Mouse button is held down anywhere)
{
Runcode();
}
if(mouse button is released)
{
StopRuncode();
}
Stack Overflow
Is this possible to detect a mouse click (Left/Right) anywhere (Inside and Outside the Form) in an if statement? And if it's possible, how?
if(MouseButtons.LeftButton == MouseButtonState.Pressed){
...
Was this page helpful?