Tapping task
Hi i'm trying to make a tapping task but i have some troubles. Here is the script i have in a loop.
t=clock.time()
button= my_mouse.get_click(timeout=0)
if button==1:
var.response_tapping = clock.time() - t0
var.count_tapping=i
log.write_vars(var_list=['serie_lettre', 'count_tapping','response_tapping'])
i=i+1
But i can't the condition if button==1: don't work, i probably don't understand how the gt_click function is working. Without this condition it's working but i need this.
Sorry for my bad english.
Comments
I didn't say it but my goal with this button==1: is to know if the left button has been used.
Hi,
A few things: firstly, your start time variable is called
t, but further on you're usingt0; this could be your problem. Secondly, it seems that you want to count all clicks, with i+1. Do you have i initiated somewhere? You could for instance also placevar.count_tapping = 0at the top of your code, and insert the linevar.count_tapping += 1in the if-statement forif button==1.Cheers
Josh
Those variables were set earlier.
The problem is that this loop us working for 6seconds. And i have to count clicks and know when or happends.
But my il condition doesn't work (i probably don't understand wich valides can take my button variable), without this condition it work, but each time i réaction the timeout a click us saved because i have no if condition
My last message was quite strange (auto correct...). I mean i'm not sure wich value return the button= my_mouse.get_click(timeout=0).
For me if we use the left button of the mouse, then mouse.get_click()=1 I am right?
That's probably the solution of all my troubles.
Hi Chokobon (great name btw),
You're right.
1corresponds to the left mouse button. However, the functionget_clickdoesn't just return the button, but also the time stamp and the mouse coordinates, soget_click() ==1, won't work. Instead you have to catch all the variables, like this for example:You can also check out the mouse documentation
Does this make sense?
Eduard