语法def python 3.5.2无效

时间:2016-11-02 12:43:00

标签: python python-3.x

请帮助我无法弄清楚这个问题。我正在尝试PixelSearch。使用Python 3.5.2,当尝试从Shell运行它时,它会在def。

上出现语法错误
import ImageGrab
import os
import time
import win32api, win32con


# Globals
# ------------------

x_pad = 464
y_pad = 244

def screenGrab():
    box = (x_pad+1, y_pad+1, x_pad+639, y_pad+477)
    im = ImageGrab.grab(box)
    im.save(os.getcwd() + '\\full_snap__' + str(int(time.time())) +
('.png', 'PNG')

def leftClick():
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
    time.sleep(.1)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
    print ("Click.") #completely optional. But nice for debugging purposes.

def leftDown():
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
    time.sleep(.1)
    print ('left Down')

def leftUp():
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
    time.sleep(.1)
    print ('left release')


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 main():
    pass

if __name__ == '__main__':
    main()

我是编程新手,所以非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

win32api.SetCursorPos((x_pad + cord[0], y_pad + cord[1])

缺少右括号

x,y = win32api.GetCursorPos():

有一个多余的冒号