Reputation: 761
I wrote a small code with python. But this part of the code doesn't work when game focused on and it doesnt respond back.
pyautogui.moveRel(-2, 4)
Also this part works when my cursor appear in menu or etc. too. But when i switched into game (when my cursor disappear and crosshair appeared) it doesn't work (doesn't matter fullscreen or else). These type of keyboard commands are in my code also but they works fine.
keyboard.is_pressed('Alt')
It's about mouse or pyautogui ?.. How can i make mouse moves correct ?
Upvotes: 0
Views: 1262
Reputation: 119
I was with the same problem in linux. For me it was wayland. After switching to X, it worked. In /etc/gdm3/custom.conf
uncomment the line #WaylandEnable=false
.
Upvotes: 1
Reputation: 761
I tried this code below:
import win32con
import win32api
win32api.mouse_event(win32con.MOUSEEVENTF_MOVE, int(10), int(10), 0, 0)
And it worked in game. I think it relative with win32con. Anyway i got it.
Upvotes: 1
Reputation:
This is how PyAutoGui works:
0,0 X increases -->
+---------------------------+
| | Y increases
| | |
| 1920 x 1080 screen | |
| | V
| |
| |
+---------------------------+ 1919, 1079
So you need to write like this:
pyautogui.moveTo(100, 200) # moves mouse to X of 100, Y of 200
or
pyautogui.moveTo(100, 200, 2) # moves mouse to X of 100, Y of 200 over 2 seconds
Upvotes: 0