Search code examples
pythonkeyloggerpythoncom

pythoncom.PumpMessages() gives warning "no reference PumpMessages() in pythoncom"


I am making a keylogger, but every source I see needs that function and it is not working properly.

I tried to update the library and it didn't fix the problem. all the code is working except the part below. I have no idea what the below means. pls, help me understand. if you know a similar function pls help. I am 14 years old so, I am not experienced will enough. 2 years in C Language. and 1-year web programming. and 1-year python pro.

obj = pyHook.HookManager()
obj.KeyDown = keypressed
obj.HookKeyboard()
pythoncom.PumpMessages()

Solution

  • This is not a Python error message. Unless I am mistaken, you are running PyCharm and you are getting a PyCharm popup when you mouse over the highlighted attribute PumpMessages.

    This is nothing to worry about. It is happening because PyCharm's analysis doesn't always know how to examine Python extensions in DLLs. As PyCharm itself says,

    This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases.

    One of the limitations of this inspection is functions in DLLs, which are dynamically dispatched.

    If you look in the file pythoncom.py you will see that it doesn't in fact contain a definition of the function PumpMessages, only two lines that import pythoncom3x.dll. The function definition lives in that DLL and PyCharm can't find it there, because it would have to execute the code to establish where to look. The message is a false alarm.

    If it bothers you, put the caret on the highlight, hit alt-Enter, click the lightbulb icon, and select one of the options to disable reporting of unresolved references, either for the function or for the entire pythoncom module. Otherwise just ignore it.

    To turn it back on, hit ctrl-alt-S (Settings), choose Editor | Inspections | Python | Unresolved references.

    So if your program isn't working as expected, look for the cause elsewhere. This warning is not the problem.