简体   繁体   中英

How to allow the mouse cursor to cross the upper screen edge on windows 10?

I would need to allow the mouse cursor to cross the upper edge of the screen. And ideally to activate/deactivate this option with some python code. I couldn't find any clue about how to do that. Any idea?

The reason why:

I am coding a psychology experiment in python (psychopy). I must constantly deviate the mouse cursor downward when it moves in a certain area of the screen. I was doing that by changing the cursor position accordingly to the desired deviation with some pymouse/psychopy functions.

However, when I ran this experiment on a new computer (I must), it froze systematically. So I tried a new method: displaying a shape (a circle) in psychopy which moves according to the real cursor+deviation while keeping the real cursor unchanged (just hiding it). However, as the real cursor isn't allowed to cross the upper edge of the screen, it is blocked at a certain height, which impedes the movements of the secondary circle cursor I created. In other words, this secondary cursor can't move as high as it should, because the real cursor cannot go higher than the upper edge of the screen.

If you have any tips about the fuller issue, please let me know!

thanks!

As you've found, the approach of drawing your own stimulus controlled by mouse position, rather than manipulating the operating system's mouse pointer, is probably more robust and flexible. So definitely continue with that approach.

However, PsychoPy relies on the operating system to report the mouse coordinates, and those are inherently bounded by the limits of the screen. So you would need to come up with your own workarounds to allow off-screen pointer motion.

  • You could try looking at what happens by using multiple monitors, ie with a second monitor set up (not necessarily visible to the participant, and not necessarily even in the same room) such that it is configured virtually to be above the primary monitor, with the mouse able to transit to it. But I have no idea how PsychoPy would deal with the mouse coordinates if the pointer transitions to a second screen.
  • Alternatively, when the mouse y coordinate hits zero, you could calculate a predicted trajectory for the mouse pointer based on its previous motion. PsychoPy will quite happily allow you to set a position for a stimulus that is partially (or completely) outside the bounds of the window, so this would allow your secondary cursor image to smoothly transition off-screen.

    How to do this sort of prediction? You could do some sort of crude linear interpolation, based on keeping a lagged record of the mouse position as few samples back in time and just keep following along a straight line between that and the last within-window position. For something that could capture curved trajectories and velocity, I'm not sure if this is relevant, but try googling for kalman predictive filter mouse tracking python

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM