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.
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 776
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 1 guest