jwjwjwjwjwjwyes
jwjwjwjwjwjwyes

Reputation: 17

cpp Simulating a smooth mouse drag

So for one of my projects I need to be able to hold a key down on my keyboard and for aslong as i hold that down it slowly moves my cursor down. I have no clue on how to perform this action. I know that SetCursorPos instantly moves the cursor but im looking for a smooth drag. Thanks

Upvotes: 1

Views: 445

Answers (1)

Oscar K
Oscar K

Reputation: 305

You do not tell us what kind of library you are using. But here is an idea: If you know that the SetCursorPos instantly moves your cursor somewhere else. You could try incrementing the position by calling SetCursorPos(current_cursor_pos + 1) everytime a button is pressed, whether or not the button is pressed, you will check in a while loop. You would have to find out how to get the current cursor position and only increment the Y.

Why increment? Because most graphical libraries place the x and y zero position on the top left of your screen. So going down along the Y axis means incrementing the Y position of your cursor.

Upvotes: 1

Related Questions