-
Notifications
You must be signed in to change notification settings - Fork 0
Class Mouse
Kristian Virtanen edited this page Oct 14, 2024
·
5 revisions
The Mouse class provides a set of methods and properties to interact with the system mouse.
Mouse.MouseX
- Gets or sets the X coordinate of the mouse cursor on the screen.
Mouse.MouseY
- Gets or sets the Y coordinate of the mouse cursor on the screen.
Mouse.IsLeftButtonDown
- Returns true if left button is down, false if not.
Mouse.IsRightButtonDown
- Returns true if right button is down, false if not.
Mouse.HideCursor()
- Hides mouse cursor from screen.
Mouse.ShowCursor()
- Shows the mouse cursors on the screen.
' Display the current mouse X and Y coordinates
TextWindow.WriteLine("Initial Mouse X: " + Mouse.MouseX)
TextWindow.WriteLine("Initial Mouse Y: " + Mouse.MouseY)
' Set new mouse X and Y coordinates
TextWindow.WriteLine("Setting mouse X to 600 and Y to 400...")
Mouse.MouseX = 600 ' Setting the mouse X coordinate
Mouse.MouseY = 400 ' Setting the mouse Y coordinate
' Verify the updated mouse coordinates
TextWindow.WriteLine("Updated Mouse X: " + Mouse.MouseX)
TextWindow.WriteLine("Updated Mouse Y: " + Mouse.MouseY)
' Hide the mouse cursor
TextWindow.WriteLine("Hiding the mouse cursor for 3 seconds...")
Mouse.HideCursor()
Program.Sleep(3)
' Show the mouse cursor
TextWindow.WriteLine("Showing the mouse cursor again.")
Mouse.ShowCursor()
namespace SmallBasicOpenEditionDll
{
class Program2
{
static void Main()
{
// Display the current mouse X and Y coordinates
Console.WriteLine($"Initial Mouse X: {Mouse.MouseX}");
Console.WriteLine($"Initial Mouse Y: {Mouse.MouseY}");
// Set new mouse X and Y coordinates
Console.WriteLine("Setting mouse X to 600 and Y to 400...");
Mouse.MouseX = 600; // Setting the mouse X coordinate
Mouse.MouseY = 400; // Setting the mouse Y coordinate
// Verify the updated mouse coordinates
Console.WriteLine($"Updated Mouse X: {Mouse.MouseX}");
Console.WriteLine($"Updated Mouse Y: {Mouse.MouseY}");
// Check if the left mouse button is pressed
Console.WriteLine("Please press and hold the left mouse button...");
System.Threading.Thread.Sleep(3000); // Wait for 3 seconds for user input
if (Mouse.IsLeftButtonDown)
{
Console.WriteLine("Left mouse button is currently pressed.");
}
else
{
Console.WriteLine("Left mouse button is not pressed.");
}
// Check if the right mouse button is pressed
Console.WriteLine("Please press and hold the right mouse button...");
System.Threading.Thread.Sleep(3000); // Wait for 3 seconds for user input
if (Mouse.IsRightButtonDown)
{
Console.WriteLine("Right mouse button is currently pressed.");
}
else
{
Console.WriteLine("Right mouse button is not pressed.");
}
// Hide the mouse cursor
Console.WriteLine("Hiding the mouse cursor for 3 seconds...");
Mouse.HideCursor();
System.Threading.Thread.Sleep(3000); // Cursor hidden for 3 seconds
// Show the mouse cursor
Console.WriteLine("Showing the mouse cursor again.");
Mouse.ShowCursor();
Console.WriteLine("All mouse operations completed.");
}
}
}