May-31-2020, 08:08 PM
(May-31-2020, 08:00 PM)DreamingInsanity Wrote:(May-31-2020, 07:08 PM)penahuse Wrote: Yes, Im using your code, its right: if I hold M without button 1 and button 2 its suposed to do nothing indeed.Right now I understand - sorry!
If I presse button 1 + button 2 the output is "do some"
But if you press M then press button 1 and button 2 too (so M + button 1+ button2 are pressed right now) the output is "do some 2" but I need just "do some" because M was pressed before other buttons.
Different is if I press buttom 1 + 2 and after buttom M, in this case i want "do some 2"
I hope this works:
import win32api def button1_pressed(): # Returns true if the left mouse button is pressed button1_state = win32api.GetAsyncKeyState(0x01) return bool(button1_state) def button2_pressed(): # Returns true if the right mouse button is pressed button2_state = win32api.GetAsyncKeyState(0x02) return bool(button2_state) def button3_pressed(): # Returns true if the M button is pressed button3_state = win32api.GetAsyncKeyState(0x4D) return bool(button3_state) while True: while button1_pressed() and button2_pressed() and not button3_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 loopit's hard to test since if I hold down 'm' it just types a load of m's so I don't know if it's working.
Mate, you almost got it..
now if button M is not pressed it do nothing but if the the M is pressed before button1 and button2 it need to "do some"
right now with this code if I presse M before button 1 and button 2 nothing happens