Control PC mouse in game.

Control PC mouse in game.

Postby guitardenver » Sat Jun 29, 2013 8:09 pm

I have a program that controls the mouse for my PC. But when I start a game (Skyrim to be specific). It stops the program and only takes input from the actual mouse. Is there a way I can have my python program control the PC mouse when the game is running?

Here is a simple program that just moves the mouse around for a little bit.
Code: Select all
import win32api, win32con, time

def click(x,y):
    win32api.SetCursorPos((x,y))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)

def move(x,y):
    win32api.SetCursorPos((x,y))

end = 0
while end < 5:
    x= 10
    y=10


    for i in range(0,1000,1):
        time.sleep(.001)
        move(x+i,y+i)

    x= 1000
    y=700

    for i in range(0,1000,1):
        time.sleep(.001)
        move(x-i,y-i)

    end = end +1

guitardenver
 
Posts: 1
Joined: Sat Jun 29, 2013 8:03 pm

Re: Control PC mouse in game.

Postby Yoriz » Sun Jun 30, 2013 4:36 pm

I think most games go out there way to stop other programs from controlling the mouse and usually in games terms and conditions you agree not to use anything that can.
Due to the reasons discussed here we will be moving to python-forum.io/ on October 1 2016
This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
User avatar
Yoriz
 
Posts: 1672
Joined: Fri Feb 08, 2013 1:35 am
Location: UK


Return to Game Development

Who is online

Users browsing this forum: No registered users and 4 guests