(May-31-2020, 04:22 PM)DreamingInsanity Wrote: In your function, you get the state of the button press. It can be an integer between 1 and 0 (pressed or not pressed).
When you return it, to get a True or False output you check if it is less than 0.
When the key isn't pressed, button_state is going to be 0:
0 < 0 = True.
Meaning when the button isn't pressed the while loop can still run. Surely you would want something like this:
return bool(button1_state)Since bool(0) returns False, and bool(1) returns True.
Am I missing something here?
Thank you for your answer.
I made some mistakes editing the posts..
Could you give a look a it:
def button1_pressed(): # Returns true if the left mouse button is pressed button1_state = win32api.GetKeyState(0x01) return button1_state < 0 def button2_pressed(): # Returns true if the right mouse button is pressed button2_state = win32api.GetKeyState(0x02) return button2_state < 0 def button3_pressed(): # Returns true if the M button is pressed button3_state = win32api.GetKeyState(0x4D) return button3_state < 0 while True: while button1_pressed() and button2_pressed(): # No matter which one is pressed first to me print("do some") while button3_pressed(): # Only if it is pressed after button1 and button2 are pressed print("do some2") if button2_pressed() == 0: break # this only breaks the inner while loop break # added an extra break else it would just be stuck in an endless loopI forgot to mention this whole code is inside a main loop.