Search the Community
Showing results for tags 'GreenShot'.
-
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 )