Sign in to follow this  
Followers 0
PartyPooper

Printing foreground window

25 posts in this topic

Valuater, just tried your code and while it works, LazyCats captplugin.dll dumps out to an exception error on completion everytime (using your code or his included example). This is not a problem with your code, it's a problem with the plugin dll itself.

Tested his V2 Capture Screen dll (captdll.dll) and it seemed to work ok.

Share this post


Link to post
Share on other sites



cool....

as long as you get the results you wanted

thats great!

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#23 ·  Posted (edited)

Slight modification to Valuaters code using v2 of LazyCats screen capturing DLL:

HotKeySet("{F9}", "OnScreenShot")
HotKeySet("{ESC}", "Terminate")

While 1
    Sleep(20)
WEnd


Func OnScreenShot()
    If Not FileExists (@scriptdir & "\screenshots") Then DirCreate (@scriptdir & "\screenshots") 
    If Not FileExists(@scriptdir & "\captdll.dll") Then FileInstall( "captdll.dll", @scriptdir & "" ,1)
    Local $Cwin1 = WinGetHandle(""); gets the handle of the active window
    Local $Cwin2 = WinGetPos($Cwin1); gets active window dimensions
    Local $Quality = 85; use -1 to save as BMP or use number between 0 - 100 to save as JPG quality
    If $Quality = -1 Then
        Local $SaveAs = ".bmp"
    Else
        Local $SaveAs = ".jpg"
    EndIf   
    Local $CaptureDirectory = @ScriptDir & "\Screenshots\"; directory uses to store screen caps
    Local $CaptureFile = @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & @MIN & "-" & @SEC & $SaveAs
    DllCall(@scriptdir & "\captdll.dll", "int", "CaptureRegion", "str", $CaptureDirectory & $CaptureFile, "int", $Cwin2[0], "int", $Cwin2[1], "int", $Cwin2[2], "int", $Cwin2[3], "int", $Quality)
    If @error Then MsgBox(262160,"ERROR","The screen was not captured",4)
EndFunc


Func Terminate()
    Exit
EndFunc

Whatever you make active (ie. desktop, window, taskbar etc) will be captured and sent to the screenshots directory as either a BMP or JPG (depending on quality setting). If using the main function (OnScreenShot) in a script, you might want to make the $Quality variable global to give users a choice of output format.

Credit goes to Valuater for the initial code showing how to capture windows and LazyCat for the DLL.

Edited by PartyPooper

Share this post


Link to post
Share on other sites

It seems I misread that whoopsie indeed you would need the extra code to select screen. Althougt using JPG at 100% quality would not break the quality because it only makes a pallete then it doesn't reduce the amount of color wich normally makes the image look bad.

In theory ofcourse thats what should happen with 100% quality (or 0 setting of compression)

I havent tested if the plugin also does this with jpg.

Screenshot can look really bad with the jpg compression on.

Share this post


Link to post
Share on other sites

hello,

i am not sure if someone will reply after all the time, but there is one question not answered: which method can capture an active window without the title bar (just the plain "gui" /picture) ?

j.


Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

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