# Replacing the mouse cursor by a picture

**URL:** <https://psychtoolbox.discourse.group/t/replacing-the-mouse-cursor-by-a-picture/1992>\
**Category:** Uncategorized\
**Created:** [October 1, 2014, 1:07pm UTC](https://psychtoolbox.discourse.group/t/replacing-the-mouse-cursor-by-a-picture/1992 "2014-10-01T13:07:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![emma.vilarem](https://avatars.discourse-cdn.com/v4/letter/e/59ef9b/32.png) [@emma.vilarem](https://psychtoolbox.discourse.group/u/emma.vilarem)\
**Post date:** [October 1, 2014, 1:07pm UTC](https://psychtoolbox.discourse.group/t/replacing-the-mouse-cursor-by-a-picture/1992/1 "2014-10-01T13:07:52Z")

</div>

Dear all,  
  
I am designing an experiment with Psychtoolbox and I would like to change the mouse cursor into a picture. I've seen many solutions for changing it into a crosshair, or a hand, or other shapes that matlab allows, but I don't manage to change the cursor by a file that I would specifiy myself (PNG file for instance).  
  
Any ideas ? or maybe this isn't possible (yet) ...  
  
Thank you very much in advance,  
  
Emma

---

<div class="post-metadata">

**Author:** ![elladawu](https://avatars.discourse-cdn.com/v4/letter/e/71c47a/32.png) [@elladawu](https://psychtoolbox.discourse.group/u/elladawu)\
**Post date:** [October 1, 2014, 3:41pm UTC](https://psychtoolbox.discourse.group/t/replacing-the-mouse-cursor-by-a-picture/1992/2 "2014-10-01T15:41:59Z")

</div>

redrawing the same texture over and over is pretty fast...

---

<div class="post-metadata">

**Author:** ![emma.vilarem](https://avatars.discourse-cdn.com/v4/letter/e/59ef9b/32.png) [@emma.vilarem](https://psychtoolbox.discourse.group/u/emma.vilarem)\
**Post date:** [October 1, 2014, 2:59pm UTC](https://psychtoolbox.discourse.group/t/replacing-the-mouse-cursor-by-a-picture/1992/3 "2014-10-01T14:59:23Z")

</div>

Thank you for your answer.  
  
Actually, I didn't give details but the idea is for the subjects to move a kind of avatar toward a chosen location on the screen with the mouse, so I thought the easier way to do it would be to replace the pointer with the avatar to accompany the trajectory ... but subjects have a limited period of time to do it (around 1000ms) and I am afraid drawing the picture on each frame is going to be a bit heavy (my script isn't light and I am already recording and saving the mouse coordinates every 10ms at the same time, which is a bit heavy too ...) ?  
  
Emma

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [October 1, 2014, 5:06pm UTC](https://psychtoolbox.discourse.group/t/replacing-the-mouse-cursor-by-a-picture/1992/4 "2014-10-01T17:06:39Z")

</div>

Drawing a single texture for a cursor image should only take microseconds. If you are concerned with the needed Screen('Flip') command throttling your mouse sampling rate to less than 10 msecs you can also use Screen('AsyncFlipBegin') - see AsyncFlipTest.m or MultiWindowLockstepTest.m for usage examples.  
-mario

---

<div class="post-metadata">

**Author:** ![emma.vilarem](https://avatars.discourse-cdn.com/v4/letter/e/59ef9b/32.png) [@emma.vilarem](https://psychtoolbox.discourse.group/u/emma.vilarem)\
**Post date:** [October 2, 2014, 12:22pm UTC](https://psychtoolbox.discourse.group/t/replacing-the-mouse-cursor-by-a-picture/1992/5 "2014-10-02T12:22:42Z")

</div>

Thank you !

I am going to look at these commands because indeed, I want the cursor-picture to appear while my stimulus is flipped in the background (two JPEG images appearing on each half of the screen), so I will need to flip only the cursor-picture without flipping my whole stimulus every 10ms because it would disrupt the continuous recording of mouse coordinates ...   

 
  
  

 
 
 
  On Wednesday, October 1, 2014 7:06 PM, "mario.kleiner@... [PSYCHTOOLBOX]" \<PSYCHTOOLBOX@yahoogroups.com\> wrote:  
  
  
  
 

&nbsp;

Drawing a single texture for a cursor image should only take microseconds. If you are concerned with the needed Screen('Flip') command throttling your mouse sampling rate to less than 10 msecs you can also use Screen('AsyncFlipBegin') - see AsyncFlipTest.m or MultiWindowLockstepTest.m for usage examples.  
-mario
