我尝试使用一些颜色检查代码和东西为Piano Tiles 2制作一个宏。这就是我得到的:
def PixCol(i_x, i_y):
import win32gui
i_desktop_window_id = win32gui.GetDesktopWindow()
i_desktop_window_dc = win32gui.GetWindowDC(i_desktop_window_id)
long_colour = win32gui.GetPixel(i_desktop_window_dc, i_x, i_y)
i_colour = int(long_colour)
return (i_colour)
def Start():
from win32 import win32api
from win32 import win32com
shell = win32com.client.Dispatch("WScript.Shell")
TileA = False
TileB = False
TileC = False
TileD = False
while True:
# Color Checking
if PixCol(1131, 473) == 0:
TileA = True
else:
TileA = False
if PixCol(1221, 473) == 0:
TileB = True
else:
TileB = False
if PixCol(1325, 473) == 0:
TileC = True
else:
TileC = False
if PixCol(1431, 473) == 0:
TileD = True
else:
TileD = False
# Auto Clicking
if TileA == True:
shell.sendKeys("a")
if TileB == True:
shell.sendKeys("s")
if TileC == True:
shell.sendKeys("d")
if TileC == True:
shell.sendKeys("f")
# End Of Code
if PixCol(1100, 60) == 15889441:
break
我尝试使用以下命令启动它。
>>> import PT2Macro
>>> PT2Macro.Start()
但不是错误地运行它。
Traceback (most recent call last):
File "<pyshell#33>", line 1, in <module>
PT2Macro.Start()
File "C:\Python34\lib\PT2Macro.py", line 22, in Start
from win32 import win32com
NameError: name 'windll' is not defined
每次尝试运行它时都会丢失相同的错误,即使我没有使用windll模块。
如果可以的话,请帮忙!
(我的规格)
Windows 7 64-bit
Python 3.4.3 x64