Getting operating system mouse info from within Maya (Python)

Getting operating system mouse info from within Maya (Python)

andy.lathamCJTQT
Contributor Contributor
527 Views
0 Replies
Message 1 of 1

Getting operating system mouse info from within Maya (Python)

andy.lathamCJTQT
Contributor
Contributor

Hi! I am writing a script for Maya that requires mouse information to be grabbed from Windows. I have managed to get the mouse coordinates by importing the pyautogui module. However that doesn't seem to have any method for detecting a mouse click.

 

I have found a method of detecting mouse clicks using pynput, but I can't seem to get the module to work from within Maya. Simply putting the import command in my script results in an error that I don't know what to do with.

from pynput.mouse import Listener

 

# Error: line 1: 'module' object has no attribute '_util'
# Traceback (most recent call last):
#   File "<maya console>", line 2, in <module>
#   File "C:/Users/andyl/Documents/maya/scripts\MouseScript.py", line 18, in <module>
#     from pynput.mouse import Listener
#   File "C:/Users/andyl/Documents/maya/scripts\pynput\__init__.py", line 40, in <module>
#     from . import keyboard
#   File "C:/Users/andyl/Documents/maya/scripts\pynput\keyboard\__init__.py", line 31, in <module>
#     backend = backend(__name__)
#   File "C:/Users/andyl/Documents/maya/scripts\pynput\_util\__init__.py", line 70, in backend
#     return importlib.import_module('._' + module, package)
#   File "C:\Program Files\Autodesk\Maya2018\bin\python27.zip\importlib\__init__.py", line 37, in import_module
#     __import__(name)
#   File "C:/Users/andyl/Documents/maya/scripts\pynput\keyboard\_win32.py", line 34, in <module>
#     import pynput._util.win32_vks as VK
# AttributeError: 'module' object has no attribute '_util' # 

 

 Note that I am intentionally importing the module from the same location as where my script is located. I installed the module for Python through pip and then copied the pynput folder to my Maya scripts folder.

 

Can anyone give any clues about what the problem is?

0 Likes
528 Views
0 Replies
Replies (0)