0

我一直在试图弄清楚如何解决这个错误。这是我第一次遇到这样的错误。我在谷歌上搜索过,我找不到解决这个问题的方法。

Traceback (most recent call last):
File "C:\Users\Parent\Desktop\NEW PROJECT\code testing and practice.py", line 49, in  <module>
print startGame()
File "C:\Users\Parent\Desktop\NEW PROJECT\code testing and practice.py", line 30, in    startGame
mousePos(304, 197)
TypeError: mousePos() takes exactly 1 argument (2 given)


def leftClick():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
time.sleep(.1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
print "Click."         

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 startGame():

#location of first menu
mousePos(304, 197)
leftClick()
time.sleep(.1)

#location of second menu
mousePos(338, 394)
leftClick()
time.sleep(.1)

#location of third menu
mousePos(576, 453)
leftClick()
time.sleep(.1)

#location of fourth menu
mousePos(311, 397)
leftClick()
time.sleep(.1)

print startGame()
4

2 回答 2

1

函数 mousePos 接受一个参数线,它看起来像一个元组或一个列表,你给两个整数参数。试试 mousePos((x, y)), x, y 是你的位置

于 2013-10-21T00:44:34.513 回答
1

将坐标放在一个元组中。

mousePos((311, 397))
于 2013-10-21T00:44:35.853 回答