跳到正文

个人记录

【原创】florr.io 挂机脚本

JacoAquamarine约 4 分钟
原文
文章信息与版本

文章信息

发布
2024年8月30日
收录
2025年12月12日
更新
2026年11月22日
篇幅
约 4 分钟

版本

  1. v1当前

如果 florr.io 上有 8 个不同颜色的 “I’m here” 按钮,且每个按钮的颜色不同,你需要为每种颜色创建不同的截图,并在代码中检查这些截图。这份 Python 代码会检测并点击所有 8 种颜色的按钮。

Python 示例:

  1. 准备截图:

    • 首先,截取 8 个不同颜色的 “I’m here” 按钮的图像,并将它们保存为不同的文件(例如 button_color1.png, button_color2.png, …)。
  2. Python 代码示例:

    Python
    import pyautogui
    import time
    
    # 所有不同颜色的 "I'm here" 按钮截图文件名
    button_images = [
        'button_color1.png',
        'button_color2.png',
        'button_color3.png',
        'button_color4.png',
        'button_color5.png',
        'button_color6.png',
        'button_color7.png',
        'button_color8.png'
    ]
    
    def find_and_click_button(images):
        for image_path in images:
            location = pyautogui.locateCenterOnScreen(image_path, confidence=0.8)
            if location:
                print(f"Found button with image {image_path} at {location}")
                pyautogui.click(location)
                return True
        return False
    
    def main():
        # 设置点击的间隔时间(单位:秒)
        interval = 60  # 每60秒检查一次
    
        print("自动点击已开始,按 Ctrl+C 结束程序。")
    
        while True:
            if find_and_click_button(button_images):
                print("Clicked one of the buttons.")
            else:
                print("No buttons found, retrying...")
    
            time.sleep(interval)
    
    if __name__ == "__main__":
        main()

使用说明:

  1. 准备截图:截取 8 种不同颜色的 “I’m here” 按钮图像,并保存为 button_color1.png 到 button_color8.png。确保每个截图与实际按钮匹配。

  2. 脚本位置:将上述代码保存为 .py 文件,并确保所有截图文件与脚本文件在同一目录下。

  3. 运行脚本:运行 Python 脚本,它将定期检查屏幕上是否出现任何一种颜色的按钮并自动点击。

  4. 点击间隔:根据需要调整 interval 变量的值来设置检查的时间间隔。

解释:

  • find_and_click_button(images):该函数遍历所有提供的截图文件,并检查屏幕上是否有匹配的按钮。如果找到匹配的按钮,它会点击该按钮并返回 True。
  • pyautogui.locateCenterOnScreen():用于在屏幕上查找按钮的中心位置。confidence 参数设置了图像匹配的置信度,可以调整以提高匹配精度。
  • pyautogui.click():模拟鼠标点击操作。
  • time.sleep():设置检查的时间间隔。
原文
存档评论3 条抓取于