Pynput cannot detect mouse clicks while in game window

97 Views Asked by At

I am trying to detect mouse clicks using pynput mouse listener while in a game window (not fullscreen). For some reason pynput only works on certain windows. It works on google but if I go into a game window no clicks will register. Here is the code:

`

def on_click(x, y, button, pressed):
    if(button==mouse.Button.right):
        if(pressed):
            #Do stuff
        else:
            #Do other stuff
    listener = mouse.Listener(on_click=on_click)
    listener.start()

' I already tried running intellij as admin and used pyauc to verify I am running as admin:

'

if __name__ == "__main__":
    if not pyuac.isUserAdmin():
        print("Re-launching as admin!")
        pyuac.runAsAdmin()
    else:
      print("Already an admin!")
      main()  # Already an admin here.`
0

There are 0 best solutions below