# Mouse position set to (0,0), but every time appear at the up-right corner of screen

**URL:** <https://discourse.psychopy.org/t/mouse-position-set-to-0-0-but-every-time-appear-at-the-up-right-corner-of-screen/5750>\
**Category:** Coding\
**Tags:** mouse\
**Created:** [November 6, 2018, 8:51pm UTC](https://discourse.psychopy.org/t/mouse-position-set-to-0-0-but-every-time-appear-at-the-up-right-corner-of-screen/5750 "2018-11-06T20:51:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![qyugit](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/qyugit/32/5165_2.png) [@qyugit](https://discourse.psychopy.org/u/qyugit)\
**Post date:** [November 6, 2018, 8:51pm UTC](https://discourse.psychopy.org/t/mouse-position-set-to-0-0-but-every-time-appear-at-the-up-right-corner-of-screen/5750/1 "2018-11-06T20:51:37Z")

</div>

Hi, I’ve encountered this problem for mouse position. For each trial, I’d like the mouse to appear at the center of the screen when it’s time for participants to respond. However, with the code below, the mouse does appear at the right time but it’s always at the up-right corner of the screen. Can anyone help me with this?

Thank you!

I’m using Mac OS Mojave.

Below is my code:

```
    if t >= click_on:
        resp_msg.draw()
        fix.setAutoDraw(False)
        click = event.Mouse(visible=True, win=win)
        # check the list of shapes
        clicked = False
        #while not clicked:
        for i, choice in enumerate(choices):
            if click.isPressedIn(choices[i]): # click any object
                clicked = True
                response = i
                click_time = expClock.getTime()
                resp_time = click_time - click_on
                if response == sample_index:
                    correct_ans = 1
                elif response != sample_index:
                    correct_ans = 0
                win.flip()
                reset_auto_draw(stimuli_set)
                continueRoutine = False
                win.mouseVisible = False
                click.setPos(newPos=(0,0))
                break # exit this loop
```

---

<div class="post-metadata">

**Author:** ![n\_m](https://avatars.discourse-cdn.com/v4/letter/n/fbc32d/32.png) [@n\_m](https://discourse.psychopy.org/u/n_m)\
**Post date:** [November 9, 2018, 10:27am UTC](https://discourse.psychopy.org/t/mouse-position-set-to-0-0-but-every-time-appear-at-the-up-right-corner-of-screen/5750/2 "2018-11-09T10:27:44Z")

</div>

Hi,  
I think you should move  
**click.setPos([0,0])** after clicked = False because now you set the position after you make the mouse invisible.

---

<div class="post-metadata">

**Author:** ![qyugit](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/qyugit/32/5165_2.png) [@qyugit](https://discourse.psychopy.org/u/qyugit)\
**Post date:** [November 10, 2018, 9:47pm UTC](https://discourse.psychopy.org/t/mouse-position-set-to-0-0-but-every-time-appear-at-the-up-right-corner-of-screen/5750/3 "2018-11-10T21:47:51Z")

</div>

Hi thank you for the help. I did try put it after clicked = False, but it resulted in the mouse being invisible.

---

<div class="post-metadata">

**Author:** ![n\_m](https://avatars.discourse-cdn.com/v4/letter/n/fbc32d/32.png) [@n\_m](https://discourse.psychopy.org/u/n_m)\
**Post date:** [November 12, 2018, 10:26am UTC](https://discourse.psychopy.org/t/mouse-position-set-to-0-0-but-every-time-appear-at-the-up-right-corner-of-screen/5750/4 "2018-11-12T10:26:52Z")

</div>

Does it work for you? The mouse appears at the right corner, then the mouse disappear, then it appear in the middle.

```auto
from psychopy import event, visual

win = visual.Window(units='pix',screen=1, color='white')
click = event.Mouse()
clicked = False
shape = visual.Circle(win=win, radius=30, pos=(20,20), fillColor= 'green', lineColor='red', units='pix')
click.setPos(newPos=(100, 100))

for i in range(0,100):
    shape.draw()
    win.flip()
click.setVisible(False)

for i in range(0,100):
    shape.draw()
    win.flip()
click.setVisible(True)
click.setPos(newPos=(0, 0))

while not clicked:
    if click.isPressedIn(shape): # click any object
        clicked = True
        shape.draw()
        win.flip()
        break # exit this loop

```

If you still have problems, could you please post the script with all components and imports defined? It should not be your full experiment, just the part that you have problems with.
