Millisecond Forums

auto mouse left click after a duration.

https://forums.millisecond.com/Topic27272.aspx

By peter - 6/9/2019

Hi all.
In my study participants will move a mouse over a board (think Ouija board). I need the mouse to auto left click after a set period of time (hopefully on a target object). This will end the trial and record the object clicked on (if any).  The hard bit is to to get the mouse to auto left click after a set period of time.  Can any you you lovely people help me with this please.
Many thanks. 
Peter
By Dave - 6/11/2019

peter - 6/10/2019
Hi all.
In my study participants will move a mouse over a board (think Ouija board). I need the mouse to auto left click after a set period of time (hopefully on a target object). This will end the trial and record the object clicked on (if any).  The hard bit is to to get the mouse to auto left click after a set period of time.  Can any you you lovely people help me with this please.
Many thanks. 
Peter

There is no way to make the mouse auto-left-click. You can, however, have the trial end after a set amount of time by specifying a /timeout (if you want to specify a maximum duration) or /trialduration (if you want to specify a fixed duration). You can record the mouse's x and y coordinates /ontrialend even if there is no click, by loggin the mouse.x and mouse.y properties.
By peter - 6/24/2019

Dave - 6/12/2019
peter - 6/10/2019
Hi all.
In my study participants will move a mouse over a board (think Ouija board). I need the mouse to auto left click after a set period of time (hopefully on a target object). This will end the trial and record the object clicked on (if any).  The hard bit is to to get the mouse to auto left click after a set period of time.  Can any you you lovely people help me with this please.
Many thanks. 
Peter

There is no way to make the mouse auto-left-click. You can, however, have the trial end after a set amount of time by specifying a /timeout (if you want to specify a maximum duration) or /trialduration (if you want to specify a fixed duration). You can record the mouse's x and y coordinates /ontrialend even if there is no click, by loggin the mouse.x and mouse.y properties.

hi could you possibly be kind enough to show me how to record mouse x and y coordinates /ontrialend, as i have only ever recorded stimulus responses. 
many thanks
Peter  
By Dave - 6/24/2019

peter - 6/24/2019
Dave - 6/12/2019
peter - 6/10/2019
Hi all.
In my study participants will move a mouse over a board (think Ouija board). I need the mouse to auto left click after a set period of time (hopefully on a target object). This will end the trial and record the object clicked on (if any).  The hard bit is to to get the mouse to auto left click after a set period of time.  Can any you you lovely people help me with this please.
Many thanks. 
Peter

There is no way to make the mouse auto-left-click. You can, however, have the trial end after a set amount of time by specifying a /timeout (if you want to specify a maximum duration) or /trialduration (if you want to specify a fixed duration). You can record the mouse's x and y coordinates /ontrialend even if there is no click, by loggin the mouse.x and mouse.y properties.

hi could you possibly be kind enough to show me how to record mouse x and y coordinates /ontrialend, as i have only ever recorded stimulus responses. 
many thanks
Peter  

Like so.

<block exampleblock>
/ postinstructions = (end)
/ trials = [
1=exampletrial;
]
</block>

<values>
/ x = -1
/ y = -1
</values>


<trial exampletrial>
/ ontrialend = [
values.x = mouse.x;
values.y = mouse.y;
]
/ stimulusframes = [1=exampletext]
/ inputdevice = mouse
/ validresponse = (0)
/ trialduration = 5000
</trial>

<text exampletext>
/ items = ("This trial will last 5 seconds. Move the mouse around, the coordinates at the end of the 5 seconds will be captured.")
/ size = (80%, 40%)
</text>

<page end>
^The mouse was at the following position:
^<%values.x%> pixels horizontal & <%values.y%> pixels vertical
</page>


<data>
/ columns = (date time subject group blocknum blockcode
trialnum trialcode stimulusitem response latency correct
mouse.x mouse.y)
/ separatefiles = true
</data>



By peter - 6/28/2019

Dave - 6/24/2019
peter - 6/24/2019
Dave - 6/12/2019
peter - 6/10/2019
Hi all.
In my study participants will move a mouse over a board (think Ouija board). I need the mouse to auto left click after a set period of time (hopefully on a target object). This will end the trial and record the object clicked on (if any).  The hard bit is to to get the mouse to auto left click after a set period of time.  Can any you you lovely people help me with this please.
Many thanks. 
Peter

There is no way to make the mouse auto-left-click. You can, however, have the trial end after a set amount of time by specifying a /timeout (if you want to specify a maximum duration) or /trialduration (if you want to specify a fixed duration). You can record the mouse's x and y coordinates /ontrialend even if there is no click, by loggin the mouse.x and mouse.y properties.

hi could you possibly be kind enough to show me how to record mouse x and y coordinates /ontrialend, as i have only ever recorded stimulus responses. 
many thanks
Peter  

Like so.

<block exampleblock>
/ postinstructions = (end)
/ trials = [
1=exampletrial;
]
</block>

<values>
/ x = -1
/ y = -1
</values>


<trial exampletrial>
/ ontrialend = [
values.x = mouse.x;
values.y = mouse.y;
]
/ stimulusframes = [1=exampletext]
/ inputdevice = mouse
/ validresponse = (0)
/ trialduration = 5000
</trial>

<text exampletext>
/ items = ("This trial will last 5 seconds. Move the mouse around, the coordinates at the end of the 5 seconds will be captured.")
/ size = (80%, 40%)
</text>

<page end>
^The mouse was at the following position:
^<%values.x%> pixels horizontal & <%values.y%> pixels vertical
</page>


<data>
/ columns = (date time subject group blocknum blockcode
trialnum trialcode stimulusitem response latency correct
mouse.x mouse.y)
/ separatefiles = true
</data>




That's awesome thank you so much
By peter - 7/21/2019

peter - 6/29/2019
Dave - 6/24/2019
peter - 6/24/2019
Dave - 6/12/2019
peter - 6/10/2019
Hi all.
In my study participants will move a mouse over a board (think Ouija board). I need the mouse to auto left click after a set period of time (hopefully on a target object). This will end the trial and record the object clicked on (if any).  The hard bit is to to get the mouse to auto left click after a set period of time.  Can any you you lovely people help me with this please.
Many thanks. 
Peter

There is no way to make the mouse auto-left-click. You can, however, have the trial end after a set amount of time by specifying a /timeout (if you want to specify a maximum duration) or /trialduration (if you want to specify a fixed duration). You can record the mouse's x and y coordinates /ontrialend even if there is no click, by loggin the mouse.x and mouse.y properties.

hi could you possibly be kind enough to show me how to record mouse x and y coordinates /ontrialend, as i have only ever recorded stimulus responses. 
many thanks
Peter  

Like so.

<block exampleblock>
/ postinstructions = (end)
/ trials = [
1=exampletrial;
]
</block>

<values>
/ x = -1
/ y = -1
</values>


<trial exampletrial>
/ ontrialend = [
values.x = mouse.x;
values.y = mouse.y;
]
/ stimulusframes = [1=exampletext]
/ inputdevice = mouse
/ validresponse = (0)
/ trialduration = 5000
</trial>

<text exampletext>
/ items = ("This trial will last 5 seconds. Move the mouse around, the coordinates at the end of the 5 seconds will be captured.")
/ size = (80%, 40%)
</text>

<page end>
^The mouse was at the following position:
^<%values.x%> pixels horizontal & <%values.y%> pixels vertical
</page>


<data>
/ columns = (date time subject group blocknum blockcode
trialnum trialcode stimulusitem response latency correct
mouse.x mouse.y)
/ separatefiles = true
</data>




That's awesome thank you so much

  Hi 
we are creating a Ouija board style study that will involve no mouse button clicking. We have a search trial were the mouse is moved around and then a selection trial where they receive feedback based on their mouse position. The search trial is currently being timed out at the block level (Block.move). This is not what we intended.

 what I cannot seem to do is to adjust the script so that the trial ends after the mouse comes to rest for a second or two, but no button is pressed. To achieve this I have searched for some kind of an iteration counter that would allow  me to compare mouse values.x and values.y coordinates over a few iterations of the trial loop to see if they change,  then if they do not change for a given number of iterations, branch to trial.select. unfortunately, I do not seem able to get this to work.

Is this possible? if not can you please suggest another way of ending the trial.search by resting the mouse for a period of time. It would also be helpful if this function only happened after a few seconds in case there is a delay between the start of the trial and participants starting their mouse movement.
To summarise, I am aiming for trial.search to start, then after 2 seconds a mechanism is activated that means stopping the mouse movement (for about a second) results in trial.search ending and the commencement of trial.select.
I would be very appreciative for any help given.
Many thanks
Peter


<expt main>
/ blocks = [1= instructions; 2=Move; 3=select; 3=Move; 4=select; 5=Move; 6=select; 7=Move; 8=select; 9=debrief]
/onexptend = [values.completed = 1]
</expt>

<block Move>
/ trials = [1 = search]
/ timeout= (8000)
</block>

<trial search>
/ stimulusframes = [1=clearscreen, bord, viewhole]
/ ontrialbegin=[values.trialcounter = values.trialcounter + 1]
/ ontrialbegin = [picture.bord.hposition = 1px * mouse.x;picture.bord.vposition = 1px * mouse.y;]
/ inputdevice = mouse
/ validresponse = (mousemove)
/ branch = [trial.search]
/ recorddata = false
</trial>

<block select>
/ trials = [1 = select]
</block>

<trial select>
/ stimulusframes = [1= Gray_Background, Black1, Black2, Black3, Black4, bord, viewhole]
/ validresponse = ( Black1, Black2, Black3, Black4)
/ recorddata = false
/ timeout= (10)
/ recorddata = true
/ ontrialend = [values.x = mouse.x; values.y = mouse.y;]
/ branch = [if (trial.select.response == "black1")trial. win]
/ branch = [if (trial.select.response == "black2")trial. lose]
/ branch = [if (trial.select.response == "black3")trial. lose]
/ branch = [if (trial.select.response == "black4")trial. win]
</trial>

By Dave - 7/21/2019

peter - 7/22/2019
peter - 6/29/2019
Dave - 6/24/2019
peter - 6/24/2019
Dave - 6/12/2019
peter - 6/10/2019
Hi all.
In my study participants will move a mouse over a board (think Ouija board). I need the mouse to auto left click after a set period of time (hopefully on a target object). This will end the trial and record the object clicked on (if any).  The hard bit is to to get the mouse to auto left click after a set period of time.  Can any you you lovely people help me with this please.
Many thanks. 
Peter

There is no way to make the mouse auto-left-click. You can, however, have the trial end after a set amount of time by specifying a /timeout (if you want to specify a maximum duration) or /trialduration (if you want to specify a fixed duration). You can record the mouse's x and y coordinates /ontrialend even if there is no click, by loggin the mouse.x and mouse.y properties.

hi could you possibly be kind enough to show me how to record mouse x and y coordinates /ontrialend, as i have only ever recorded stimulus responses. 
many thanks
Peter  

Like so.

<block exampleblock>
/ postinstructions = (end)
/ trials = [
1=exampletrial;
]
</block>

<values>
/ x = -1
/ y = -1
</values>


<trial exampletrial>
/ ontrialend = [
values.x = mouse.x;
values.y = mouse.y;
]
/ stimulusframes = [1=exampletext]
/ inputdevice = mouse
/ validresponse = (0)
/ trialduration = 5000
</trial>

<text exampletext>
/ items = ("This trial will last 5 seconds. Move the mouse around, the coordinates at the end of the 5 seconds will be captured.")
/ size = (80%, 40%)
</text>

<page end>
^The mouse was at the following position:
^<%values.x%> pixels horizontal & <%values.y%> pixels vertical
</page>


<data>
/ columns = (date time subject group blocknum blockcode
trialnum trialcode stimulusitem response latency correct
mouse.x mouse.y)
/ separatefiles = true
</data>




That's awesome thank you so much

  Hi 
we are creating a Ouija board style study that will involve no mouse button clicking. We have a search trial were the mouse is moved around and then a selection trial where they receive feedback based on their mouse position. The search trial is currently being timed out at the block level (Block.move). This is not what we intended.

 what I cannot seem to do is to adjust the script so that the trial ends after the mouse comes to rest for a second or two, but no button is pressed. To achieve this I have searched for some kind of an iteration counter that would allow  me to compare mouse values.x and values.y coordinates over a few iterations of the trial loop to see if they change,  then if they do not change for a given number of iterations, branch to trial.select. unfortunately, I do not seem able to get this to work.

Is this possible? if not can you please suggest another way of ending the trial.search by resting the mouse for a period of time. It would also be helpful if this function only happened after a few seconds in case there is a delay between the start of the trial and participants starting their mouse movement.
To summarise, I am aiming for trial.search to start, then after 2 seconds a mechanism is activated that means stopping the mouse movement (for about a second) results in trial.search ending and the commencement of trial.select.
I would be very appreciative for any help given.
Many thanks
Peter


<expt main>
/ blocks = [1= instructions; 2=Move; 3=select; 3=Move; 4=select; 5=Move; 6=select; 7=Move; 8=select; 9=debrief]
/onexptend = [values.completed = 1]
</expt>

<block Move>
/ trials = [1 = search]
/ timeout= (8000)
</block>

<trial search>
/ stimulusframes = [1=clearscreen, bord, viewhole]
/ ontrialbegin=[values.trialcounter = values.trialcounter + 1]
/ ontrialbegin = [picture.bord.hposition = 1px * mouse.x;picture.bord.vposition = 1px * mouse.y;]
/ inputdevice = mouse
/ validresponse = (mousemove)
/ branch = [trial.search]
/ recorddata = false
</trial>

<block select>
/ trials = [1 = select]
</block>

<trial select>
/ stimulusframes = [1= Gray_Background, Black1, Black2, Black3, Black4, bord, viewhole]
/ validresponse = ( Black1, Black2, Black3, Black4)
/ recorddata = false
/ timeout= (10)
/ recorddata = true
/ ontrialend = [values.x = mouse.x; values.y = mouse.y;]
/ branch = [if (trial.select.response == "black1")trial. win]
/ branch = [if (trial.select.response == "black2")trial. lose]
/ branch = [if (trial.select.response == "black3")trial. lose]
/ branch = [if (trial.select.response == "black4")trial. win]
</trial>


Would it be possible for you to please post self-contained and runable code (i.e. please include all elements and files the code needs to actually run). Isolated code snippets are not particularly useful.
By Dave - 7/21/2019


In a nutshell, I would do something like this:

<values>
/ lastx = -1
/ lasty = -1
</values>

<block example>
/ trials = [1-4 = start]
</block>

<trial start>
/ pretrialpause = 100
/ stimulusframes = [1=move]
/ inputdevice = mouse
/ validresponse = (mousemove)
/ branch = [
trial.move_or_rest;
]
/ recorddata = false
</trial>

<trial move_or_rest>
/ stimulusframes = [1=move_or_rest]
/ inputdevice = mouse
/ validresponse = (mousemove, noresponse)
/ timeout = 2000
/ branch = [
if (trial.move_or_rest.response !=0) {
trial.move_or_rest;
} else {
values.lastx = mouse.x;
values.lasty = mouse.y;
trial.end
}
]

</trial>

<trial end>
/ stimulusframes = [1=end]
/ inputdevice = mouse
/ validresponse = (lbuttondown)
</trial>

<text move>
/ items = ("Move the mouse.")
/ erase = false
/ size = (20%, 20%)
</text>

<text move_or_rest>
/ items = ("Move the mouse. If you stop at any point for 2 seconds, the trial sequence ends.")
/ erase = false
/ size = (20%, 20%)
</text>

<text end>
/ items = ("Mouse was rested for two seconds. The resting coordinates were <%values.lastx%>, <%values.lasty%>.")
/ erase = false
/ size = (20%, 20%)
</text>