このスクリプトを実行しようとしています:
import pythoncom, pyHook
def OnMouseEvent(event):
# called when mouse events are received
print 'MessageName:',event.MessageName
print 'Message:',event.Message
print 'Time:',event.Time
print 'Window:',event.Window
print 'WindowName:',event.WindowName
print 'Position:',event.Position
print 'Wheel:',event.Wheel
print 'Injected:',event.Injected
print '---'
# return True to pass the event to other handlers
return True
# create a hook manager
hm = pyHook.HookManager()
# watch for all mouse events
hm.MouseAll = OnMouseEvent
# set the hook
hm.HookMouse()
# wait forever
pythoncom.PumpMessages()
エラーが表示されます:
Traceback (most recent call last):
File "C:\Python26\Test\click.py", line 1, in <module>
import pythoncom, pyHook
File "C:\Python26\Test\pythoncom.py", line 13, in <module>
pythoncom.PumpMessages() #will wait forever
AttributeError: 'module' object has no attribute 'PumpMessages'
シェルに pythoncom をインポートし、コマンド pythoncom.PumpMessages() を記述した後、問題なく実行されるため、これは奇妙です。この問題はどのように解決できますか?