Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么鼠标指针停在屏幕边缘?_Python_Mouseevent - Fatal编程技术网

Python 为什么鼠标指针停在屏幕边缘?

Python 为什么鼠标指针停在屏幕边缘?,python,mouseevent,Python,Mouseevent,当鼠标指针位于屏幕边缘时,如果我们继续向该方向移动鼠标,它将停留在边缘 为什么? 我试图用python中的鼠标钩子来理解这一点,发现指针的位置移到了那个方向,但随后又反弹到了边缘 我正在尝试破解,看看这是怎么发生的,我能让鼠标指针停留在屏幕外的位置,而不是反弹到边缘吗?如果是这样的话,它能在一个司机身上完成吗 In [71]: def mousehook(evt): ...: print(f"mousehook, {evt}") ...: In [72]: import

当鼠标指针位于屏幕边缘时,如果我们继续向该方向移动鼠标,它将停留在边缘

为什么? 我试图用python中的鼠标钩子来理解这一点,发现指针的位置移到了那个方向,但随后又反弹到了边缘

我正在尝试破解,看看这是怎么发生的,我能让鼠标指针停留在屏幕外的位置,而不是反弹到边缘吗?如果是这样的话,它能在一个司机身上完成吗

In [71]: def mousehook(evt):
    ...:     print(f"mousehook, {evt}")
    ...:

In [72]: import mouse

In [73]: mouse.hook(mousehook)
Out[73]: <function __main__.mousehook(evt)>

mousehook, MoveEvent(x=997, y=1080, time=1536040579.9038901)            <----y=1080, mouse position is at the bottom of my screen now, and I'm moving it down
mousehook, MoveEvent(x=996, y=1090, time=1536040579.9278252)
mousehook, MoveEvent(x=996, y=1092, time=1536040579.9378557)
mousehook, MoveEvent(x=998, y=1094, time=1536040579.9446943)
mousehook, MoveEvent(x=1002, y=1097, time=1536040579.951711)
mousehook, MoveEvent(x=1006, y=1102, time=1536040579.960732)
mousehook, MoveEvent(x=1013, y=1110, time=1536040579.9687536)
mousehook, MoveEvent(x=1018, y=1113, time=1536040579.9737678)
mousehook, MoveEvent(x=1022, y=1120, time=1536040579.9817884)
mousehook, MoveEvent(x=1023, y=1121, time=1536040579.990813)
mousehook, MoveEvent(x=1022, y=1120, time=1536040579.9978318)
mousehook, MoveEvent(x=1016, y=1132, time=1536040580.005868)
mousehook, MoveEvent(x=1009, y=1124, time=1536040580.0128717)
mousehook, MoveEvent(x=1002, y=1139, time=1536040580.0249045)           <----y=1139, cross the screen edge 
mousehook, MoveEvent(x=996, y=1121, time=1536040580.0289156)
mousehook, MoveEvent(x=994, y=1118, time=1536040580.0399437)
mousehook, MoveEvent(x=992, y=1108, time=1536040580.0459607)
mousehook, MoveEvent(x=989, y=1108, time=1536040580.0509746)
mousehook, MoveEvent(x=986, y=1103, time=1536040580.0600011)
mousehook, MoveEvent(x=983, y=1098, time=1536040580.0670166)
mousehook, MoveEvent(x=982, y=1095, time=1536040580.0750391)
mousehook, MoveEvent(x=982, y=1092, time=1536040580.0840635)
mousehook, MoveEvent(x=982, y=1086, time=1536040580.0910902)
mousehook, MoveEvent(x=982, y=1083, time=1536040580.0991023)
mousehook, MoveEvent(x=982, y=1080, time=1536040580.1091292)            <----y=1080, position mouse back to the edge
In [74]: mouse.unhook_all()
[71]中的
:def鼠标夹(evt):
…:打印(f“mousehook,{evt}”)
...:
在[72]:导入鼠标
In[73]:mouse.hook(mousehook)
出[73]:

mousehook,MoveEvent(x=997,y=1080,time=1536040579.9038901)鼠标移动很可能会告诉光标移动到不存在的坐标,但如果它们在屏幕外,GUI中就没有实际将光标移动到屏幕外的点。这可能导致光标在屏幕外任何方向丢失的情况。你为什么要实现这一点?我正在考虑用类似鼠标的设备模拟某种虚拟现实体验。屏幕只是虚拟现实世界的一部分。假设有两个屏幕,一个在前面,一个在后面。一个经过校准的类似鼠标的设备可以将屏幕上的指针按其指向的方向移动,你必须实际旋转180度并将其指向屏幕背面,才能使指针移动到那里。所以这可以提供某种虚拟现实交互。啊,我明白了。好主意。