Sign in to follow this  
Followers 0

GreenShot Screen Capture Automation


7 posts in this topic

Posted (edited)

GreenShot (http://getgreenshot.org/) is a nice, free for personal use, screen capture utility. It is designed to be running all the time (in the system notification tray) and triggered with a Global Hotkey (Print Scrn).

I prefer to only run it when I need it and have it exit when I'm done, so I wrote this simple script. It starts the utility (if it's not already running), triggers a capture operation, waits for me to finish editing/saving the image, and then closes the utility.

The only tricky part was determining when it was ready to accept a HotKey to start the capture. My solution was to monitor it's IO count.

The only downside is that it leaves the tray icon visable until the next tray refresh, because I killed it instead of closing it down normally. (Known problem).

- Alan G -

GreenShot_Auto_X86_V1.0.zip

; =====================================================================
;    Start GreenShot
;    Send it a PrintScreen keyboard commnad
;    Wait for a capture
;    Shut it down
; =====================================================================
    Global $ProcessName = "Greenshot.exe"                                                ; Process Name
    Global $WindowTitle = "Greenshot image editor"                                        ; Image Editor Window Title
    Global $RunCmd = "C:\Program Files (x86)\Greenshot\Greenshot.exe"                    ; Program run Command
    Global $WorkingDir = ""                                                                ; Working Directory

    ; If GreenShot is not already running

    If NOT ProcessExists( $ProcessName ) Then

        ; Execute GreenShot

        If NOT ShellExecute( $RunCmd, "", $WorkingDir ) Then
            MsgBox( 16, @ScriptFullPath & " - Error", _
            "Program failed to execute. $RunCmd = '" & $RunCmd & "'." )
            Exit( 1 )
        Else

            ; Wait for the GreenShot process to exist

            If NOT ProcessWait( $ProcessName, 5 ) Then
                MsgBox( 16, @ScriptFullPath & " - Error", _
                "Process did not start. $ProcessName = '" & $ProcessName & "'." )
                Exit( 1 )
            Else

                ; Wait for a minimum number of IO (So we know it's ready)

                Global $Ready = False
                For $i = 1 To 20
                    Global $IOStats = ProcessGetStats( $ProcessName, 1 )
                    If $IOStats[1] > 4 Then
                        $Ready = True
                        ExitLoop
                    EndIf
                    Sleep( 250 )
                Next ; $i

                If NOT $Ready Then
                    MsgBox( 16, @ScriptFullPath & " - Error", _
                    "Process IO Reads not > 700. $ProcessName = '" & $ProcessName & "', $IOStats[1] = '" & $IOStats[1] & "'." )
                    Exit( 1 )
                EndIf

            EndIf ; NOT ProcessWait
        EndIf ; NOT ShellExecute
    EndIf ; NOT ProcessExists

; Send GreenShot a PrintScreen Keyboard command to
; initiate a Capture

    Send( "{PRINTSCREEN}" )

; Wait for the Greenshot Image Editor Window to Open
; after I take a shot

    If NOT WinWaitActive( $WindowTitle, "", 300 ) Then
            MsgBox( 16, @ScriptFullPath & " - Error", _
            "Image Editor Window did not open. $WindowTitle = '" & $WindowTitle & "'." )
            Exit( 1 )
        EndIf

; Wait for the Greenshot Image Editor Window to Close
; then kill the process

    WinWaitClose( $WindowTitle )
    ProcessClose( $ProcessName )
    If NOT ProcessWaitClose( $ProcessName, 5 ) Then
        MsgBox( 16, @ScriptFullPath & " - Error", _
        "Process failed to close. $ProcessName = '" & $ProcessName & "'." )
        Exit( 1 )
    EndIf

; All done

    Exit( 0 )
Edited by AGlassman
1 person likes this

Share this post


Link to post
Share on other sites



Posted

Hi,

I am one of the Greenshot developers and just joined the AutoIt forum as I have plans to make some Greenshot functionality available to AutoIt (and other applications).

I noticed this post and I want to ask you what reason you have to stop Greenshot?

Will also explain you a better way to do this, but need to check this befor posting.

P.s.

Make sure you use the latest version, we are currently working on our 1.0 and a release candidate will be available soon.

Best wishes,

Robin

Share this post


Link to post
Share on other sites

Posted (edited)

Hi,

I am one of the Greenshot developers and just joined the AutoIt forum as I have plans to make some Greenshot functionality available to AutoIt (and other applications).

Very nice!

I noticed this post and I want to ask you what reason you have to stop Greenshot?

Probably due to the fact that nobody replied to the topic in these three months that have passed!

@AGlassman

Very nice work, thanks 4 shared...

Regards,

João Carlos.

Edited by JScript

Share this post


Link to post
Share on other sites

Posted

I noticed this post and I want to ask you what reason you have to stop Greenshot?

I use a large number of utilities in the course of a day's work. Some, like GreenShot, only rarely and I don't want them running all the time. I realize that GreenShot takes almost no resoruces when it's idle, but I prefer to keep the number of active processes (and tray icons) to a minimum.

Share this post


Link to post
Share on other sites

Posted

I must admit to being a tad bewildered by this topic ... perhaps it hasn't really been thought through properly, or I'm just missing something.

In other words, I'm struggling slightly to come up for a plausible scenario for the Automation element.

I can understand leaving an App like Greenshot running, for a security purpose perhaps, but then you'd continue to leave it running, otherwise I'd just set a hotkey to start it or just manually run it at need.

On top of that, I'd avoid something like Greenshot and code my own solution, or just use/modify one of the many provided here over the years.

But then, perhaps Greenshot does something special, like notice when a specific window appears and react to it, taking a screenshot? I've built watcher programs myself, that do that, then shut down the PC ... possibly displaying the screenshot on next boot. Handy if a program doesn't have it's own shutdown option. Nothing like that has been declared though, so it seems unlikely.

Share this post


Link to post
Share on other sites

Posted

Ive used Greenshot for a few days then i re-installed my computer and forgot about it ts not a bad little utility.

@TheSaint its just a screen capture program but i liked the fact i could capture parts of the screen without the need of an editor and cropping, only thing that would of been nice was the naming of the file after maybe thats in there but i never really looked for it and use to F2 every file for the rename.

Share this post


Link to post
Share on other sites

Posted

@TheSaint its just a screen capture program but i liked the fact i could capture parts of the screen without the need of an editor and cropping, only thing that would of been nice was the naming of the file after maybe thats in there but i never really looked for it and use to F2 every file for the rename.

There are scripts here, that do all you want in that regard - a specific portion of screen &/or a specific window only. I use them in several of my programs.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • Screen Edit
      By Mechaflash

      Easily capture, edit, and save images from your desktop.

      When working on multiple projects and building documentation, taking screenshots, editing them, and then inserting them into files eats up some time. This little program helps to reduce some of that time by auto-opening your screen capture in the editor of your choice while having the ability to auto-save the captures in a sequenced file naming pattern.

      See the for some detailed information.

    • Screen Edit
      By Mechaflash
  • Recently Browsing   0 members

    No registered users viewing this page.