Python SetCursorPos error? Or online game cause it?
Question: The code works perfectly with no errors until I unminimize the game.After a
lot of tries to locate why SetCursorPos doesnt work , I understoud that it did
not have a problem with the cords , but it refuses to move to the location
when its on the window of the game. The code so far is:

    
    
    from PIL import ImageGrab
    import os
    import time
    import win32con , win32api
    
    x_pad = 2
    y_pad = 27
    
    
    def start():
        #location of first menu
        mousePos((682, 519))
        leftClick()
        time.sleep(.1)
        leftClick()
        time.sleep(.5)
    
        #location of second menu
        mousePos((1208, 528))
        leftClick()
        time.sleep(.5)
    
        #location of third menu
        mousePos((921, 479))
        leftClick()
        time.sleep(.5)
    
        #location of fourth menu
        mousePos((651, 350))
        leftClick()
        time.sleep(.5)
    
    def screenGrab():
        box = (x_pad+1,y_pad+1,x_pad+1362,y_pad+770)
        im = ImageGrab.grab(box)
        im.save(os.getcwd() + '\\full_snap__' + str(int(time.time())) +
    '.png', 'PNG')
    
    
    
    def mousePos(cord):
        win32api.SetCursorPos((x_pad + cord[0], y_pad + cord[1]))
    
    
    def get_cords():
        x,y = win32api.GetCursorPos()
        x = x - x_pad
        y = y - y_pad
        print x,y
    
    
    def leftClick():
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
        time.sleep(.1)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
        print "Click."
    
    
    def main():
        pass
    
    
    if __name__ == "__MAIN__":
        main()
    

And when i run start() i get this:

    
    
     Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32
     Type "copyright", "credits" or "license()" for more information.
     >>> ================================ RESTART ================================
     >>> 
     >>> start() 
     'Traceback (most recent call last):
       File "<pyshell#0>", line 1, in <module>
         start()
      File "C:\Users\User\Desktop\py\game.py", line 12, in start
       mousePos((682, 519))
        File "C:\Users\User\Desktop\py\game.py", line 42, in mousePos
            win32api.SetCursorPos((x_pad + cord[0], y_pad + cord[1]))
            error: (0, 'SetCursorPos', 'No error message is available')'
      >>>
    

I have no idea why this happens and i have tryed many solutions from this site
,could it be the game? What i want to know is if the game is the cause of the
error or I have missed something , and if there is a posible solution.


Answer: are you running through the tutorial from
<http://dev.tutsplus.com/tutorials/how-to-build-a-python-bot-that-can-play-
web-games--active-11117>?

Shouldn't be an issue with it, i went through the same and it worked.

