Python - manipulating mouse and keyboard inputs in various applications

35 Views Asked by At

I tried various of mouse and keyboard controlling libraries(such as pyautogui and mouse) for Python, they usually work for the applications that doesn't require fullscreen but they don't work properly for some applications such as games. I tried to make it work for few different games but I cannot be sure if it doesn't for all since I don't know what exactly is the problem.

In these, the mouse usually performs the position commands, it goes where it needs to go but never performs the click actions. For keyboards, they don't perform key actions in these.

So, I'm looking for what is inhibiting the code from working properly in those some apps and how to fix it.

Note: OS is Windows

1

There are 1 best solutions below

3
Kuberan JS On

This is a longshot method but it's worth trying.

  1. Take a screenshot of your screen.
  2. assign it to a variable named frame using cv2.imread("path to image") function.
  3. find your screen's dimensions using the below command.

height,width,_ = frame.shape

now that you have the dimensions, you can easily manipulate the mouse coordinates and access the entire screen.

Upvote if it helps.