Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

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 using t0; 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 place var.count_tapping = 0 at the top of your code, and insert the line var.count_tapping += 1 in the if-statement for if 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. 1 corresponds to the left mouse button. However, the function get_click doesn't just return the button, but also the time stamp and the mouse coordinates, so get_click() ==1, won't work. Instead you have to catch all the variables, like this for example:

    button, (x,y), time = mouse.get_click()
    if button == 1:
       # do stuff
    

    You can also check out the mouse documentation
    Does this make sense?

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.