On a machine with Ubuntu20.04 (description Ubuntu 20.04.4 LTS, Codename: focal) and python3.8.11 I've installed pyautogui, and it works well. But on a machine with Ubuntu22.04 (description Ubuntu 22.04 LTS, Codename: jammy) and python3.10.4 pyautogui does not work, because pyautogui.position() does not show the correct coordinate of the current mouse position. How can I solve this problem? Any suggestion is welcome. Thanks in advance!
I am also searching for a solution to this issue and this is what I have found.

Try restarting your system after installing pyautogui.
Try using just one monitor.

Thanks,
Rahul
pyautogui does not work with python3.10, but works well with python3.8 on ubuntu20.04