Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14155

Multiprocessing and threading are too slow

$
0
0

I'm creating a script to play the new fortnite festival mode(just for fun not trying to beat anyone other than my friends) and while the code works mostly it still misses notes occasionally. I believe this is because the code is just running to slow for the speed of the game. I have seen similair things in guitar hero so I figured python would be fast enough however it doesn't appear to be. I have tried both threading and multiprocessing, as well as just plain code however they all apear to slow. I am using vscode if that helps.

import pyautoguiimport multiprocessingrun = Truedef a():    while run:       if pyautogui.pixel(1010, 1150) [0] == 255:            pyautogui.keyDown("d")            pyautogui.keyUp("d")def b():    while run:        if pyautogui.pixel(1200, 1150) [0] == 255:            pyautogui.keyDown("f")            pyautogui.keyUp("f")def c():    while run:        if pyautogui.pixel(1400, 1150) [0] == 255:            pyautogui.keyDown("j")            pyautogui.keyUp("j")def d():    while run:        if pyautogui.pixel(1560, 1150) [0] == 255:            pyautogui.keyDown("k")            pyautogui.keyUp("k")
if __name__ == '__main__':    process_a = multiprocessing.Process(target=a)    process_b = multiprocessing.Process(target=b)    process_c = multiprocessing.Process(target=c)    process_d = multiprocessing.Process(target=d)    process_a.start()    process_b.start()    process_c.start()    process_d.start()    process_a.join()    process_b.join()    process_c.join()    process_d.join()

I've tried all sorts of stuff including cython(I just couldn't get it too work). My code could be flawed and I realize there some timing issues to hit the notes perfectly but, it's still missing quite a few notes. It seems as if it's just on a different part of the code when a note goes by. Please let me know of any fixes.


Viewing all articles
Browse latest Browse all 14155

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>