Skip to content

Describe simulator scene with gpt-4-vision #12

Open
@elkraneo

Description

// Define a function to capture the screen of the Xcode simulator app window
func captureSimulatorWindow() {
    let targetAppName = "Simulator"  // The name of the Xcode simulator app
    
    if let windowList = CGWindowListCopyWindowInfo(.optionOnScreenOnly, kCGNullWindowID) as? [[String: AnyObject]] {
        for window in windowList {
            if let windowOwnerName = window[kCGWindowOwnerName] as? String, windowOwnerName.contains(targetAppName) {
                if let windowID = window[kCGWindowNumber] as? CGWindowID {
                    let screenCaptureSession = ScreenCaptureSession(windowID: windowID)
                    
                    // Start the screen capture session for the Xcode simulator window
                    screenCaptureSession.startCapture { image, error in
                        if let image = image {
                            // Process the captured image
                            // For example, you can save the image to a file
                            saveImageToFile(image: image)
                        } else if let error = error {
                            // Handle the error
                            print("Error capturing the simulator window: \(error.localizedDescription)")
                        }
                    }
                }
            }
        }
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions