Automatic mouse movement
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.
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.
- akakyouryuu
- Regular
- Posts: 153
- Joined: Fri Nov 30, 2012 10:29 am
- Contact:
Automatic mouse movement
When dialog is displayed, I want to move the mouse to the yes button of a dialog automatically.
Can ren'py do this?
Can ren'py do this?
- akakyouryuu
- Regular
- Posts: 153
- Joined: Fri Nov 30, 2012 10:29 am
- Contact:
Re: Automatic mouse movement
I resolved this problem by oneself.
I write the below code.
I can't explain the particulars of this in English, but maybe you will understand it, if you read it.
---automouse.rpy
I write the below code.
I can't explain the particulars of this in English, but maybe you will understand it, if you read it.
---automouse.rpy
Code: Select all
#functions
#automouse_jump(x, y)
#jump to (x,y)
#automouse_move(x, y, time_ms)
#move to (x,y) in time_ms
#automouse_get_pos() return (x, y)
# get mouse coordinates
init python:
import pygame
def automouse_yesno_prompt(*args):
automouse_move(250, 150, 100)
return yesno_prompt_org(*args)
def automouse_jump(x, y):
x, y = automouse_windowmode_pos_to_true_pos(x, y)
pygame.mouse.set_pos([x, y])
def automouse_move(goalx, goaly, time_ms):
goalx, goaly = automouse_windowmode_pos_to_true_pos(goalx, goaly)
starttime = pygame.time.get_ticks()
startx, starty = pygame.mouse.get_pos()
speedx = ( float(goalx - startx) / float(time_ms) )
speedy = ( float(goaly - starty) / float(time_ms) )
while(1):
nowtime = pygame.time.get_ticks()
pygame.mouse.set_pos([speedx*(nowtime-starttime)+startx, speedy*(nowtime-starttime)+starty])
if nowtime - starttime >= time_ms:
break
def automouse_get_pos():
x, y = pygame.mouse.get_pos()
return automouse_true_pos_to_windowmode_pos(x, y)
def automouse_blackline_pos():
videoinfo = pygame.display.Info()
now_w = float(videoinfo.current_w)
now_h = float(videoinfo.current_h)
def_w = float(config.screen_width)
def_h = float(config.screen_height)
if now_w * (def_h / def_w) <= now_h:
return (0, int(( now_h - now_w * (def_h / def_w) ) / 2))
else:
return (int(( now_w - now_h * (def_w / def_h) ) / 2), 0)
def automouse_windowmode_pos_to_true_pos(x, y):
videoinfo = pygame.display.Info()
now_w = float(videoinfo.current_w)
now_h = float(videoinfo.current_h)
def_w = float(config.screen_width)
def_h = float(config.screen_height)
bl_x, bl_y = automouse_blackline_pos()
bl_x = float(bl_x)
bl_y = float(bl_y)
X = x * (now_w - 2*bl_x) / def_w
Y = y * (now_h - 2*bl_y) / def_h
return (int(X + bl_x), int(Y + bl_y))
def automouse_true_pos_to_windowmode_pos(x, y):
videoinfo = pygame.display.Info()
now_w = float(videoinfo.current_w)
now_h = float(videoinfo.current_h)
def_w = float(config.screen_width)
def_h = float(config.screen_height)
bl_x, bl_y = automouse_blackline_pos()
bl_x = float(bl_x)
bl_y = float(bl_y)
X = (float(x) - bl_x) * def_w / (now_w - 2*bl_x)
Y = (float(y) - bl_y) * def_h / (now_h - 2*bl_y)
return (int(X), int(Y))
yesno_prompt_org = layout.yesno_prompt
layout.yesno_prompt = automouse_yesno_prompt
- kuri_chii
- Regular
- Posts: 69
- Joined: Sat Apr 27, 2013 10:34 am
- Completed: RHWIMY beta 1.0
- Projects: Right here where I met you, Love Snatch, Monarchy High
- Organization: VND - AWA
- IRC Nick: Kuri
- Deviantart: franzzzz002
- Skype: franz.mole
- Location: Somewhere in Asia
- Contact:
Re: Automatic mouse movement
does this work at the latest renpy?
The best way showing your feelings is to write Novel Stories :3

DeviantArt | Monarchy High | RHWIMY | Love Snatch

DeviantArt | Monarchy High | RHWIMY | Love Snatch
- nyaatrap
- Crawling Chaos
- Posts: 1824
- Joined: Mon Feb 13, 2012 5:37 am
- Location: Kimashi Tower, Japan
- Contact:
Re: Automatic mouse movement
Yes. I'm using his script on my latest commercial game made with ren'py 6.15.5
Though he added screen actions:
Use these actions instead of automouse_yesno_prompt(*args)
Though he added screen actions:
Code: Select all
class MouseMove(Action):
def __init__(self, x, y, time):
self.x = x
self.y = y
self.time = time
def __call__(self):
automouse_move(self.x, self.y, self.time)
class MouseJump(Action):
def __init__(self, x, y):
self.x = x
self.y = y
def __call__(self):
automouse_jump(self.x, self.y)- kuri_chii
- Regular
- Posts: 69
- Joined: Sat Apr 27, 2013 10:34 am
- Completed: RHWIMY beta 1.0
- Projects: Right here where I met you, Love Snatch, Monarchy High
- Organization: VND - AWA
- IRC Nick: Kuri
- Deviantart: franzzzz002
- Skype: franz.mole
- Location: Somewhere in Asia
- Contact:
Re: Automatic mouse movement
nyaatrap wrote:Yes. I'm using his script on my latest commercial game made with ren'py 6.15.5
Though he added screen actions:Use these actions instead of automouse_yesno_prompt(*args)Code: Select all
class MouseMove(Action): def __init__(self, x, y, time): self.x = x self.y = y self.time = time def __call__(self): automouse_move(self.x, self.y, self.time) class MouseJump(Action): def __init__(self, x, y): self.x = x self.y = y def __call__(self): automouse_jump(self.x, self.y)
where should I put his script and your action?
The best way showing your feelings is to write Novel Stories :3

DeviantArt | Monarchy High | RHWIMY | Love Snatch

DeviantArt | Monarchy High | RHWIMY | Love Snatch
- nyaatrap
- Crawling Chaos
- Posts: 1824
- Joined: Mon Feb 13, 2012 5:37 am
- Location: Kimashi Tower, Japan
- Contact:
Re: Automatic mouse movement
Anywhere on your .rpy file, or make a new .rpy file and paste them.
To use this, write actions in the screens like this: http://lemmasoft.renai.us/forums/viewto ... 29#p276565
To use this, write actions in the screens like this: http://lemmasoft.renai.us/forums/viewto ... 29#p276565
- XxrenxX
- Veteran
- Posts: 267
- Joined: Tue Oct 02, 2012 2:40 am
- Projects: Chasing
- Deviantart: bara-ettie
- Location: Canada
- Contact:
Re: Automatic mouse movement
I want to use something like this in my game but I don't understand this code or how to get it to work.
I found the automatic move in the screen actions, values and functions page.
And it's something I want to implement in my game for the yes/no prompts. In short move the mouse to the center between the yes and no. Added the button so players could set this function to on and off but the code he created seems to be different so it wont work. Also 'automatic move' isn't a preference?
I'm just overall confused by this and I don't see a point in starting a new topic since this one already exists.
I found the automatic move in the screen actions, values and functions page.
Code: Select all
hotspot (351,260,32,21) action Preference("automatic move", "enable")
hotspot (383,260,38,18) action Preference("automatic move", "disable")I'm just overall confused by this and I don't see a point in starting a new topic since this one already exists.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot]