I used pyautogui to simulate rotation angle in World Of Warcraft
I try to press the "right button of the mouse " + "move the mouse" distance, it seems that the camera cannot be rotated, and it has not been resolved so far T.T
(I am not sure , if there is a demo for this)
So I use keyDown('right') + keyUp('left') to rotate the camera
I encountered a problem, I learned that it takes 2s to rotate a circle of 360,
So when I calculate the angle
pyautogui. keyDown('right')
press_time = ange * (360/ 2000) / 1000
time. sleep(press_time)
pyautogui. keyDown('up')
However, I found that the angle is actually too large. It seems that the angle of rotation is greater than 360 degrees by pressing the right 2s. Can someone help me?
However, I found that the angle is actually too large. It seems that the angle of rotation is greater than 360 degrees by pressing the right 2s. Can someone help me?
I assume your formula is wrong.
First you need to calculate press_time in seconds for 1 degree: 2/360
(assuming that it takes 2 seconds to rotate by 360 degrees).
Then, you can get duration of button pressing in seconds for certain angle by multiplying angle by that constant (remember: time.sleep
accepts seconds as an argument):
press_time = angle * (2/360)
pyautogui.keyDown('right')
time.sleep(press_time)
pyautogui.keyDown('up')
Also, calculate press_time before pressing down, since calculation of press_time takes a little bit of time, and button will be pressed all the time while python doing his calculations.