| Reference | Downloads | Github

PsychoPy Code does not run on first attempt, but is fine on Second - using "mouse"

I have a strange behaviour ( reproducible ) when running from Builder.
( I am not a programmer as can easily be seen by the code )

I am checking for a mouse position on top of image data ( image covers entire screen ).
When I edit ANYTHING !!! the code runs, but no mouse position is displayed, and the routine does not end after the specified number of clicks. I have to kill via “esc”.
One example of an edit: Changing “” to " " in MouseInfo
Running again without any changes will nicely run the program.

Here is the code ( Routine is named “trial” )
[ I expect to edit a lot in Python and thus I am very verbose to make it easier to find items ]

At Begin Routine so all variables are defined

Click_before = False
Click_count = 0
when = trialClock.getTime() #time here is in Routine
where = mouse.getPos()
MouseInfo = “”

#Each Frame
Click = mouse.getPressed()
if Click[0] == 1 and Click_before == False: #left button down only
when = trialClock.getTime() #time in Routine
where = mouse.getPos() # get [x,y]
Click_before = True
Click_count += 1
x_pos = round(where[0],3)
y_pos = round(where[1],3)
when_dum = round(when,4)
#To simplify printing in PsychoPy Window
MouseInfo = “Where: [” + str(x_pos) +"," + str(y_pos) + "]\nWhen: " + str(when_dum)
if Click[0] == 0:
Click_before = False
if Click_count > 9: # default stop at 9
continueRoutine = False

I have no clue where I might have made a mistake - but it only occurs if I edit the code of the mouse-component of “trial”

Thanks in advance

This seems to be an issue with the recognition of mouse events from an external mouse.
I went into Python and saw that my functionality was already there as basic

I inserted a “print” into the Python and saw that the external mouse clicks are unreliably recognized. When the external mouse is moved while clicking, it registers after a few pixels.
I put this down to Windows OS rather than PsychoPy.