Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-3-5-sonnet-20241022· AnthropicHugging Face LMArena Human Preference 140K

整理一個python對windows系統擷圖的腳本給我

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with DeepSeekdeepseek-r1-0528’s answer.
  1. User

    整理一個python對windows系統擷圖的腳本給我

  2. Claude Assistant

    我會提供一個使用Python擷取Windows螢幕截圖的腳本,並加上註解說明:

    import pyautogui
    import time
    from datetime import datetime
    import os
    
    # 建立儲存截圖的資料夾
    if not os.path.exists("screenshots"):
        os.makedirs("screenshots")
    
    def take_screenshot():
        # 取得當前時間作為檔名
        timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
        filename = f"screenshots/screenshot_{timestamp}.png"
        
        try:
            # 截取全螢幕
            screenshot = pyautogui.screenshot()
            # 儲存圖片
            screenshot.save(filename)
            print(f"截圖已儲存: {filename}")
            return True
        except Exception as e:
            print(f"截圖發生錯誤: {str(e)}")
            return False
    
    # 主程式
    if __name__ == "__main__":
        # 等待3秒後開始截圖
        print("準備開始截圖...")
        time.sleep(3)
        take_screenshot()
    

    使用這個腳本前需要先安裝必要的套件:

    pip install pyautogui
    

    這個腳本的主要功能:

    1. 自動建立screenshots資料夾存放截圖
    2. 使用當前時間作為檔名
    3. 執行時會等待3秒,讓你有時間切換到想要截圖的畫面
    4. 擷取整個螢幕畫面並儲存為PNG格式

    如果你想要更進階的功能,我可以提供:

    • 擷取指定視窗
    • 擷取特定區域
    • 定時自動截圖
    • 加入GUI介面

    需要這些進階功能嗎?

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.