鱼C论坛

 找回密码
 立即注册
查看: 3199|回复: 10

[已解决]请问怎么安装PyMouse

[复制链接]
发表于 2020-2-5 23:15:26 | 显示全部楼层 |阅读模式
30鱼币
pip install PyMouse 试过了 网上教程先安装pyHook也安装了
可就是调不出
pip list 能看到 pymouse 和pyhook
QQ浏览器截图20200205230853.png QQ浏览器截图20200205231038.png QQ浏览器截图20200205231350.png
最佳答案
2020-2-5 23:15:27
将 C:\Users\86139\AppData\Local\Programs\Python\Python37\lib\site-packages\pymouse\__init__.py 文件改成这样:

  1. # -*- coding: iso-8859-1 -*-

  2. #   Copyright 2010 Pepijn de Vos
  3. #
  4. #   Licensed under the Apache License, Version 2.0 (the "License");
  5. #   you may not use this file except in compliance with the License.
  6. #   You may obtain a copy of the License at
  7. #
  8. #       http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. #   Unless required by applicable law or agreed to in writing, software
  11. #   distributed under the License is distributed on an "AS IS" BASIS,
  12. #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. #   See the License for the specific language governing permissions and
  14. #   limitations under the License.

  15. """The goal of PyMouse is to have a cross-platform way to control the mouse.
  16. PyMouse should work on Windows, Mac and any Unix that has xlib.

  17. See http://github.com/pepijndevos/PyMouse for more information.
  18. """

  19. import sys
  20. from threading import Thread

  21. class PyMouseMeta(object):

  22.     def press(self, x, y, button = 1):
  23.         """Press the mouse on a givven x, y and button.
  24.         Button is defined as 1 = left, 2 = right, 3 = middle."""

  25.         raise NotImplementedError

  26.     def release(self, x, y, button = 1):
  27.         """Release the mouse on a givven x, y and button.
  28.         Button is defined as 1 = left, 2 = right, 3 = middle."""

  29.         raise NotImplementedError

  30.     def click(self, x, y, button = 1):
  31.         """Click the mouse on a givven x, y and button.
  32.         Button is defined as 1 = left, 2 = right, 3 = middle."""

  33.         self.press(x, y, button)
  34.         self.release(x, y, button)

  35.     def move(self, x, y):
  36.         """Move the mouse to a givven x and y"""

  37.         raise NotImplementedError

  38.     def position(self):
  39.         """Get the current mouse position in pixels.
  40.         Returns a tuple of 2 integers"""

  41.         raise NotImplementedError

  42.     def screen_size(self):
  43.         """Get the current screen size in pixels.
  44.         Returns a tuple of 2 integers"""

  45.         raise NotImplementedError

  46. class PyMouseEventMeta(Thread):
  47.    
  48.     deamon = True
  49.     capture = False
  50.     state = True

  51.     def stop(self):
  52.         self.state = False

  53.     def click(self, x, y, button, press):
  54.         """Subclass this method with your click event handler"""

  55.         pass

  56.     def move(self, x, y):
  57.         """Subclass this method with your move event handler"""

  58.         pass



  59. if sys.platform.startswith('java'):
  60.     from .java_ import PyMouse

  61. elif sys.platform == 'darwin':
  62.     from .mac import PyMouse, PyMouseEvent

  63. elif sys.platform == 'win32':
  64.     from .windows import PyMouse, PyMouseEvent

  65. else:
  66.     from .unix import PyMouse, PyMouseEvent
复制代码

最佳答案

查看完整内容

将 C:%users\86139\AppData\Local\Programs\Python\Python37\lib\site-packages\pymouse\__init__.py 文件改成这样:
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-2-5 23:15:27 | 显示全部楼层    本楼为最佳答案   
将 C:\Users\86139\AppData\Local\Programs\Python\Python37\lib\site-packages\pymouse\__init__.py 文件改成这样:

  1. # -*- coding: iso-8859-1 -*-

  2. #   Copyright 2010 Pepijn de Vos
  3. #
  4. #   Licensed under the Apache License, Version 2.0 (the "License");
  5. #   you may not use this file except in compliance with the License.
  6. #   You may obtain a copy of the License at
  7. #
  8. #       http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. #   Unless required by applicable law or agreed to in writing, software
  11. #   distributed under the License is distributed on an "AS IS" BASIS,
  12. #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. #   See the License for the specific language governing permissions and
  14. #   limitations under the License.

  15. """The goal of PyMouse is to have a cross-platform way to control the mouse.
  16. PyMouse should work on Windows, Mac and any Unix that has xlib.

  17. See http://github.com/pepijndevos/PyMouse for more information.
  18. """

  19. import sys
  20. from threading import Thread

  21. class PyMouseMeta(object):

  22.     def press(self, x, y, button = 1):
  23.         """Press the mouse on a givven x, y and button.
  24.         Button is defined as 1 = left, 2 = right, 3 = middle."""

  25.         raise NotImplementedError

  26.     def release(self, x, y, button = 1):
  27.         """Release the mouse on a givven x, y and button.
  28.         Button is defined as 1 = left, 2 = right, 3 = middle."""

  29.         raise NotImplementedError

  30.     def click(self, x, y, button = 1):
  31.         """Click the mouse on a givven x, y and button.
  32.         Button is defined as 1 = left, 2 = right, 3 = middle."""

  33.         self.press(x, y, button)
  34.         self.release(x, y, button)

  35.     def move(self, x, y):
  36.         """Move the mouse to a givven x and y"""

  37.         raise NotImplementedError

  38.     def position(self):
  39.         """Get the current mouse position in pixels.
  40.         Returns a tuple of 2 integers"""

  41.         raise NotImplementedError

  42.     def screen_size(self):
  43.         """Get the current screen size in pixels.
  44.         Returns a tuple of 2 integers"""

  45.         raise NotImplementedError

  46. class PyMouseEventMeta(Thread):
  47.    
  48.     deamon = True
  49.     capture = False
  50.     state = True

  51.     def stop(self):
  52.         self.state = False

  53.     def click(self, x, y, button, press):
  54.         """Subclass this method with your click event handler"""

  55.         pass

  56.     def move(self, x, y):
  57.         """Subclass this method with your move event handler"""

  58.         pass



  59. if sys.platform.startswith('java'):
  60.     from .java_ import PyMouse

  61. elif sys.platform == 'darwin':
  62.     from .mac import PyMouse, PyMouseEvent

  63. elif sys.platform == 'win32':
  64.     from .windows import PyMouse, PyMouseEvent

  65. else:
  66.     from .unix import PyMouse, PyMouseEvent
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-2-5 23:51:07 | 显示全部楼层
pymouse 和你的python版本不匹配吧
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-2-6 08:43:52 | 显示全部楼层
不行的话试试IDLE或者cmd
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-2-6 11:35:33 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-2-6 14:05:45 | 显示全部楼层
一个账号 发表于 2020-2-6 11:35
推荐使用 wheel 文件安装:https://fishc.com.cn/forum.php?mod=viewthread&tid=149371&page=1&extra=#pid4 ...

你确定这种方法是可行的?
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-2-6 14:09:14 | 显示全部楼层
zltzlt 发表于 2020-2-6 14:05
你确定这种方法是可行的?

确定,我查了一下,都是推崇这种方法。
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-2-6 14:09:50 | 显示全部楼层
一个账号 发表于 2020-2-6 14:09
确定,我查了一下,都是推崇这种方法。

你试过吗?
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-2-6 14:16:33 | 显示全部楼层

pip 好像装不了 pyHook
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-2-6 14:21:40 | 显示全部楼层
一个账号 发表于 2020-2-6 14:16
pip 好像装不了 pyHook

pyHook 不支持 Python 3.6+ 的版本。
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2020-2-6 17:32:32 | 显示全部楼层
zltzlt 发表于 2020-2-5 23:15
将 C:%users\86139\AppData\Local\Programs\Python\Python37\lib\site-packages\pymouse\__init__.py 文件 ...

亲试成功 太感谢你了  我搞了好几天了
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-3-4 01:03

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表