Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

GreenShot Screen Capture Automation

GreenShot Screen Capture

  • Please log in to reply
6 replies to this topic

#1 AGlassman

AGlassman

    Seeker

  • Active Members
  • 11 posts

Posted 04 April 2012 - 03:45 PM

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 -

Attached File  GreenShot_Auto_X86_V1.0.zip   280.53KB   359 downloads

Plain Text         
; ===================================================================== ;    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, 04 April 2012 - 04:01 PM.

  • JScript likes this







#2 Apex75

Apex75

    Seeker

  • New Members
  • 1 posts

Posted 06 June 2012 - 08:42 PM

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

#3 JScript

JScript

    I'm back ... I miss, why not!

  • Active Members
  • PipPipPipPipPipPip
  • 1,195 posts

Posted 07 June 2012 - 12:11 PM

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, 07 June 2012 - 12:13 PM.

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)
Spoiler

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!       


#4 AGlassman

AGlassman

    Seeker

  • Active Members
  • 11 posts

Posted 10 December 2012 - 02:45 PM

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.

#5 TheSaint

TheSaint

    *** Knight Templar ***

  • MVPs
  • 5,443 posts

Posted 10 December 2012 - 03:23 PM

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.

Make sure brain is in gear before opening mouth! Ignoring those who try to divert conversation with irrelevancies. If I put effort into communication, I expect you to read properly & fully, or just not comment. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox


#6 Gotemp

Gotemp

    Seeker

  • Active Members
  • 42 posts

Posted 10 December 2012 - 03:32 PM

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.

#7 TheSaint

TheSaint

    *** Knight Templar ***

  • MVPs
  • 5,443 posts

Posted 11 December 2012 - 11:34 AM

@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.

Make sure brain is in gear before opening mouth! Ignoring those who try to divert conversation with irrelevancies. If I put effort into communication, I expect you to read properly & fully, or just not comment. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox






Also tagged with one or more of these keywords: GreenShot, Screen Capture

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users