Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CaptureScreen and SaveBitmap is not working properly #609

Open
1 of 3 tasks
prathishbv opened this issue Aug 29, 2023 · 0 comments
Open
1 of 3 tasks

CaptureScreen and SaveBitmap is not working properly #609

prathishbv opened this issue Aug 29, 2023 · 0 comments

Comments

@prathishbv
Copy link

prathishbv commented Aug 29, 2023

my screen shot function work fine but When I tried to open my screen shot it shows like purple and green background.
cosco_ui-login_3_12_14_16

  • Robotgo version (or commit ref): github.com/go-vgo/robotgo v0.100.10

  • Go version: golang:1.19.3

  • Gcc version: Installed: 4:11.2.0-1ubuntu1
    Candidate: 4:11.2.0-1ubuntu1

  • Operating system and bit: Ubuntu 22.04.2 LTS 64-bit

  • Can you reproduce the bug at Examples:

    • Yes (provide example code)
    • No
    • Not relevant
  • Provide example code:
    func TakeScreenshot(vendorID string, integrationType string, subVendor string) (filename string, err error) {
    screenWidth, screenHeight := robotgo.GetScreenSize()

    // Capture a screenshot of the entire screen
    ct := time.Now()
    screenshot := robotgo.CaptureScreen(0, 0, screenWidth, screenHeight)
    fileName := fmt.Sprintf("%s_%s_%s_%s.png", subVendor, integrationType, vendorID, ct.Format("15_04_05"))

    // Save the screenshot as a PNG file
    robotgo.SaveBitmap(screenshot, "tmp/"+fileName)
    // defer os.Remove(fileName) // Remove the local screenshot file when done

    file, err := os.Open("tmp/" + fileName)
    if err != nil {
    return fileName, err
    }
    defer file.Close()

    // Upload to S3 bucket using PutObject API call
    sess := session.Must(session.NewSessionWithOptions(session.Options{
    SharedConfigState: session.SharedConfigEnable,
    }))

    svc := s3.New(sess)
    bucketName := os.Getenv("s3Bucket")
    _, err = svc.PutObject(&s3.PutObjectInput{
    Bucket: aws.String(bucketName),
    Key: aws.String("errors/" + fileName),
    Body: file,
    })
    if err != nil {
    return fileName, err
    }

    return fileName, nil
    }

Description

I am getting the screenshot with green, purple background.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant