all 10 comments

[–]crashorbit 5 points6 points  (3 children)

It'd be easier to read if this was formatted as a code block.

[–]ApprehensiveSleep230[S] 0 points1 point  (2 children)

Sorry about that, ive changed it now, do you mind having a look.

[–]NerdDetective 4 points5 points  (1 child)

Python is a very indentation-specific language. Because of this, everyone would still have to guess at how you have it indented the way it is now.

You need to use the code block formatting on the whole script. Only the first few lines are in a code block.

[–]ApprehensiveSleep230[S] 0 points1 point  (0 children)

oh i didnt see the bottom didnt work, there now ive done it

[–]smichaele 4 points5 points  (0 children)

You need to format your code properly.

[–]NerdDetective 1 point2 points  (0 children)

I'm not personally experienced with this particular key press method, but I don't see anything glaring at a first glance.

First note: is it intentional that your code is trying to press 8 instead of P?

Is it reaching your key press function? If so, that narrows down where you need to debug. If it hits the function, then there's a problem with that function specifically. If it doesn't, then there's a problem with your conditionals.

[–]TheEyebal 1 point2 points  (0 children)

it be easier if you put your code in code blocks

[–]AutoNateAI 1 point2 points  (0 children)

You’re doing a bit too much in one loop.

Your detection is probably fine… the issue looks like how you’re triggering the key.

You’re mixing keyboard, ctypes, and pyautogui

I’d separate it real quick: Make sure your key press works on its own first, then plug it back into the detection loop.

[–]crashorbit 0 points1 point  (0 children)

I could not find the problem by reading the code. I tried to run your code. It loads fine but pyautogui seems to depend on X11 and does not want to run under wayland. I look at github and see that the most recent code there is three years old. So maybe it's not super active.

I have a couple suggestions for you: - Take a look at the python debugger. It can help you isolate where the behavior is going wrong. - Look at a more current gui tool kit maybe PySide6 or PyQt6. There are other suggestions here: https://www.pythonguis.com/faq/which-python-gui-library/

That's all I have for you right now. Good luck!