mouse

Detect if any mouse button is being pressed, and if so, which one?

点点圈 提交于 2021-02-19 07:40:49
问题 Basically, I want to query if any mouse button is being pressed and if so, which one. The problem is that I don't use a (constantly focused) UI environment. It is meant to be able to run in the background while the OS is focused on another window. I just have a Swing GUI set up for easy controlling. How could I do this? (By the way, I am trying to query it inside of a loop, so setting up an event listener wouldn't be efficient.) 回答1: As mentioned by others you would need to use JNA in order

Detect if any mouse button is being pressed, and if so, which one?

南楼画角 提交于 2021-02-19 07:39:31
问题 Basically, I want to query if any mouse button is being pressed and if so, which one. The problem is that I don't use a (constantly focused) UI environment. It is meant to be able to run in the background while the OS is focused on another window. I just have a Swing GUI set up for easy controlling. How could I do this? (By the way, I am trying to query it inside of a loop, so setting up an event listener wouldn't be efficient.) 回答1: As mentioned by others you would need to use JNA in order

Mouse position on extended displays

你。 提交于 2021-02-17 05:54:25
问题 I could not find anything on this particular problem, so here it goes! I am interested in changing the position of the mouse cursor programmatically. Cursor.Position = new Point(x, y); works as expected using a single monitor. However, when I plug in a second one and choose to extend the desktop, changing the cursor's coordinates only works relative to the main screen. So, does anyone know how to tell the cursor that I want to move to a different screen? 回答1: Get the width and height of your

How to check if and which mouse button is pressed in Swing

守給你的承諾、 提交于 2021-02-17 05:47:46
问题 How can I check if currently any mouse button is pressed and if so, which one it is? The thing is that I need to use this kind of information in MouseListener.mouseEntered() . I checked MouseEvent but I could not find the method which would help me. The getButton() method seems to only return value if there has been change in buttons' state. Is there a way to find this out without manually keeping track of this somehow vie MouseListener.mousePressed()/mouseReleased() methods. 回答1: How can I

Not getting an output for OpenGL to print line using mouse click

 ̄綄美尐妖づ 提交于 2021-02-16 14:59:07
问题 My aim is to draw a line using mouse click. When you click the first click it reads the coordinates then when for the nest click it will draw the line using GL_LINES with first and second points. int first, x1, yi, x2, yj, ww = 600, wh = 400; void drawl() { glClear(GL_COLOR_BUFFER_BIT); glLineWidth(5.00); glColor3f(0,1,0); glBegin(GL_LINES); glVertex2i(x1,yi); glVertex2i(x2,yj); glEnd(); glFlush(); } void Display() { glClearColor(0.5, 0.5, 0.5, 1.0); glColor3f(0.7, 0.4, 0.0); glClear(GL_COLOR

How to draw a rectangle in C# using a mouse

陌路散爱 提交于 2021-02-10 18:00:42
问题 I want to draw a rectangle on a form in C#. I read and found this article. Are there any samples or tutorials available ? The article was not very helpful. 回答1: The article you linked appears to be C++, which may explain why it didn't help you much. If you create events for MouseDown and MouseUp, you should have the two corner points you need for a rectangle. From there, it's a matter of drawing on the form. System.Drawing.* should probably be your first stop. There are a couple of tutorials

How to precisely track the mouse cordinates without skips

陌路散爱 提交于 2021-02-10 14:40:48
问题 I need a way to track the mouse coordinates more precisely than this code. If you run this code and move your mouse really fast or change directions fast, the coordinates might look this: 50 and then 40. It seems that when the mouse moves fast it doesn't track all the points the pointer covers, like in this example there are 10 coordinates that it skips. If I move it slowly, there's no problem. I need a way to track all the pointer coordinates with no skips. I've tried the sample on Code

What terminal command can I use to terminate the cursor/mouse process on a MacOSX?

左心房为你撑大大i 提交于 2021-02-08 11:13:12
问题 What terminal command can I use to terminate the cursor/mouse process on a MacOSX? I'm changing the size of the mouse using another command in the terminal and now I need to restart the process that displays the cursor. I have searched for hours for a similar topic, but couldn't find one. Does anybody know how to achieve this? 回答1: If by "changing the size of the mouse using another command in the terminal", you mean that you set the System Preferences value (i.e. using 'defaults' command),

How can I change the mouse cursor image?

谁说胖子不能爱 提交于 2021-02-08 07:36:21
问题 I need to change the cursor image. Whenever the mouse is over my form I need to load my own image from a local path. I am using version 1.1 of the .NET framwork. Here is what I have tried: Cursor = new Cursor(GetType(), Application.StartupPath+ "\\windowfi.cur"); But this throws an exception: Value cannot be null. Parameter name: dataStream 回答1: Cursor class has a constructor that takes in cur file path as a parameter. Use that. Like this: this.Cursor = new Cursor("<your_cur_file_path"); 回答2:

Moving Mouse in C# (coordinate units)

自古美人都是妖i 提交于 2021-02-07 08:29:31
问题 I'm trying to make Teamviewer like piece of software for fun, which allows one person to view another person's screen and click and all that. Anyway, I have most all of the socket stuff done, but I don't know how to get the mouse clicks to work correctly. Here is the code I found online for moving the mouse programmatically: public static class VirtualMouse { // import the necessary API function so .NET can // marshall parameters appropriately [DllImport("user32.dll")] static extern void