Search
Star
Feedback
Setup for Free
© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
✅ Detect holding mouse from in and outside the form - C#
C
C#
•
3y ago
•
39 replies
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
c# Detect mouse clicks anywhere (Inside and Outside the Form)
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
)
{
.
.
.
C#
Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Recent Announcements
Similar Threads
Was this page helpful?
Yes
No
Similar Threads
✅ Detect key press outside of the form
C
C# / help
2y ago
How do I detect if the mouse position is outside a panel and its children in WinForm
C
C# / help
2y ago
✅ mouse events outside wpf
C
C# / help
3y ago
❔ I want to pass information from Form3 to listBox in Form2
C
C# / help
3y ago