How to force move mouse?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
AHAKuo
Regular
Posts: 41
Joined: Tue Feb 06, 2018 11:10 am
Projects: SoUnd Is ToxIc
Organization: AHAKuo
Tumblr: ahakuo
Deviantart: ahakuo
Contact:

How to force move mouse?

#1 Post by AHAKuo »

I have seen this done on Doki Doki Literature Club when the mouse gets forcefully moved to a location.

How does it happen? How can I make the mouse move to a place by force?
Working on:

Image

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: How to force move mouse?

#2 Post by IrinaLazareva »


User avatar
AHAKuo
Regular
Posts: 41
Joined: Tue Feb 06, 2018 11:10 am
Projects: SoUnd Is ToxIc
Organization: AHAKuo
Tumblr: ahakuo
Deviantart: ahakuo
Contact:

Re: How to force move mouse?

#3 Post by AHAKuo »

IrinaLazareva wrote: Thu Feb 22, 2018 12:44 pm You can use MouseMove() action.
https://www.renpy.org/doc/html/screen_a ... #MouseMove
Thanks for the response!

Hmm. And how would that code be implemented so that the mouse forcefully moves to a choice?
Working on:

Image

ReDZiX
Regular
Posts: 32
Joined: Thu Jan 04, 2018 12:42 pm
Contact:

Re: How to force move mouse?

#4 Post by ReDZiX »

Probably with something like this:

Code: Select all


#A WARNING: The x and y positions given are roughly the center of my screen,
#where I placed the exit button,
#you might have to test and change it to your own resolution for your game.

screen force_mouse_move():

    on "show":
        action MouseMove(x=650, y=350, duration=.3)

    timer .5 repeat True action MouseMove(x=650, y=350, duration=.3)

    textbutton "Click Me" xalign .5 yalign .5 action Return()

label start:
    scene black #Thi is just so I can see the button crearly

    call screen force_mouse_move

    "..."

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: How to force move mouse?

#5 Post by IrinaLazareva »

AHAKuo wrote: Thu Feb 22, 2018 1:06 pm Hmm. And how would that code be implemented so that the mouse forcefully moves to a choice?
Just to select the value of coordinates.

One more example:

Code: Select all

screen myscreen():
    style_prefix 'choice'
    vbox:
        align(.5, .5)
        spacing 30
        textbutton "No" action NullAction()
        textbutton "Yep" action Hide('myscreen')        
        textbutton "Nope" action NullAction()    
    on 'show' action MouseMove(config.screen_width/2, config.screen_height/2, 3)

label start:
    '?'
    show screen myscreen
    '!'
    return
P.S. in an example the cursor is forced exactly on the center of the screen.

User avatar
MilywayObree
Newbie
Posts: 17
Joined: Sun Jan 28, 2018 11:24 am
Completed: None so far, pending to be exact
Projects: DDLC, The notebook and other secret projects
Organization: Vocastin/Oriaa Pro-Creations
Deviantart: MexicoRPelino
Github: HizashiroTakahashi
Skype: PixelMINEGaming
Location: Philippines
Contact:

Re: How to force move mouse?

#6 Post by MilywayObree »

You could do it like this...

Code: Select all

default currposition = 0
init python:
    def MoveMouseFunc():
        currposition = renpy.get_mouse_pos()
        tpos = [640, 345]
        if currposition[1] < tpos[1]:
            renpy.display.draw.set_mouse_pos((currposition[0] * 9 + tpos[0]) / 10.0, (currposition[1] * 9 + tpos[1]) / 10.0)
now define a screen to do this certain action...

Code: Select all

screen riggedmousescreen():
    timer 1.0/30.0 repeat True action Function(MoveMouseFunc)
once you did all of those...

Code: Select all

label start:
    show screen riggedmousescreen
    e "I am controlling your mouse"
    return
Hope it helped! :smile:
Just Monika.

User avatar
AHAKuo
Regular
Posts: 41
Joined: Tue Feb 06, 2018 11:10 am
Projects: SoUnd Is ToxIc
Organization: AHAKuo
Tumblr: ahakuo
Deviantart: ahakuo
Contact:

Re: How to force move mouse?

#7 Post by AHAKuo »

ReDZiX wrote: Thu Feb 22, 2018 2:00 pm Probably with something like this:

Code: Select all


#A WARNING: The x and y positions given are roughly the center of my screen,
#where I placed the exit button,
#you might have to test and change it to your own resolution for your game.

screen force_mouse_move():

    on "show":
        action MouseMove(x=650, y=350, duration=.3)

    timer .5 repeat True action MouseMove(x=650, y=350, duration=.3)

    textbutton "Click Me" xalign .5 yalign .5 action Return()

label start:
    scene black #Thi is just so I can see the button crearly

    call screen force_mouse_move

    "..."


OMG THIS IS THE BEST CODE!

Thank you so much for this help! It really saved me :D BIG THANKS! <3
Working on:

Image

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Toma