我正在尝试创建一个程序来设置一个图像,该图像位于与该程序相同的目录中,作为我的桌面背景。
这张图片是我事先拍摄的屏幕截图。这就是我到目前为止所知道的:
import time as t
import pyautogui
import ctypes
# screenshot
myScreenshot = pyautogui.screenshot()
myScreenshot.save(r'bg.bmp')
# wait a little
t.sleep(1)
# set image as background
SPI_SETDESKWALLPAPER = 20
ctype
所以,我在这里有一个程序,我将使用它为蛇游戏制作一个机器人。但它实在太慢了。有什么办法加快速度吗?
import pyautogui
running = True
color = (231, 71, 29)
while running == True:
s = pyautogui.screenshot()
for x in range(s.width):
for y in range(s.height):
if s.getpixel((x, y)) == color:
pyautogui.click(x,
PyAutoGui,它添加了point,并使它成为int而不是浮点数,我可能只是愚蠢。这是我第一次尝试这个libary,错误来自于Point(x=1558,y=287),如果我试图在屏幕截图代码中使用它,我只会得到一个错误,像这个float()参数必须是一个字符串或实数,而不是'Point‘。
from platform import release
import pytesseract
import pyautogui
import time
import pyautogui
from pynput.mouse import Listener
test = pyautogui.po
我试图用用户引入的名称保存一个屏幕截图文件,但是当它到达屏幕快照保存命令时,它会在程序初始化时重置为第一个值。
我设置了一些打印函数来调试程序,但是我只发现它正在重置变量,但不知道为什么,我做了一个正在工作的安排,但我确信这不是最好的方法。
import pyautogui
import time
from tkinter import *
Serial = "String"
im1 = pyautogui.screenshot
window = Tk()
window.title("Escanea número de serie")
window.geo
虽然在截图中不止一次找到了搜索到的"aaa.png“照片,但它只找到了1张。我希望它能找到所有这些照片。我能为它做些什么?
iml = pyautogui.screenshot(region=(158, 284, 628, 679))
while True:
if pyautogui.locateOnScreen('aaa.png', confidence=0.9, grayscale=True) != None:
for a in pyautogui.locateOnScreen('aaa.png'):
当某个彩色像素出现在定义的屏幕截图中时,我尝试单击它,然后重新拍摄屏幕截图,扫描更多的特定彩色像素,一旦找到一个,就单击一个,依此类推。我认为我的代码正在拍摄屏幕截图,然后扫描像素的颜色,一旦找到颜色,它就会单击它,但它不会重新拍摄屏幕截图,而是继续扫描屏幕截图,寻找更多具有匹配颜色的像素并单击它们。如何中断for循环,该循环在找到并单击像素后扫描像素,然后在重新拍摄屏幕截图时重新开始该过程?我的代码如下,谢谢! from pyautogui import *
import pyautogui
import time
import keyboard
import random
import
#! python3
import pyautogui
import time
pyautogui.screenshot('first.png') #take a SS of my entire screen
check = pyautogui.locateCenterOnScreen('first.png') # set the value of check to center of screen assuming it will be the same as the SS...it will
print(check) #(960, 540) is the
我正在使用pyautogui截图我的当前屏幕,我想知道是否可以通过剪贴板访问该图像进行进一步处理?代码: import pyautogui
import time
x = 1
while x < 4:
capture = pyautogui.screenshot('/Users/Desktop/Screen/image'+str(x)+'.png')
x += 1
time.sleep(2) 谢谢。