Jump to content

Capture Screen dll


Lazycat
 Share

Recommended Posts

  • Replies 76
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

  • 4 weeks later...

Hi LazyCat-

Very nice job on creating a dll for AutoIT. I think this is a wonderful addition to the "native" tools that make AutoIT richer. In my case, I have been using IrFanView to get screen captures from remote computers and have found that IFV's command line parameters offer a huge amount of flexibility. You can output any of IFV's dozens of formats, perform size and color depth reduction, output directly to printer, capture images with incremental names, etc. etc. My point is, that, unless you plan to turn this into a lifelong project (like Irfan has), AutoIT users may still want to look at IrfanView when they plan their next screen capture project. Certainly, for 98% of applications your dll is fantastic, but for those "sticky" ones, check out IrfanView...

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

AutoIT users may still want to look at IrfanView when they plan their next screen capture project. Certainly, for 98% of applications your dll is fantastic, but for those "sticky" ones, check out IrfanView...

Noone say this is alpha and omega, surely Irfan have a lots of more power. But if you don't need many, just simple capture, it's can still be preferable - it's can be tightly integrated (especially plugin version) and it's really small.
Link to comment
Share on other sites

Lazycat this is truely very nice.

Thanks!

I've used it to make an incremental screen capture for our guys who write training manuals to aid screen shots. I am probably going to modify it to allow BMP save and Compression levels when it starts when time permits

Here is my code if anyone is interested.

$g_szVersion = "MultiScreenDump"
If WinExists($g_szVersion) Then  Exit MsgBox (262144,"Error","Screen Capture is already running") 
AutoItWinSetTitle($g_szVersion)

FileInstall ("captdll.dll", @tempdir & "\captdll.dll", 1)
Global $count = 1, $dest

MsgBox (262144, "Screen Capture", "Press PrintScreen to capture screen shot press escape to quit")
While $dest = ""
$dest = FileSelectFolder ( "Select a destination", "" ,1)
Wend

HotKeySet ("{PRINTSCREEN}", "Capture")
HotKeySet ("{ESC}", "quit")

While 1
    Sleep (100)
Wend

Func Capture()
    If FileExists ($dest & "\image_" & $count & ".jpg") <> 0 then 
    Do 
        $count +=1
    until FileExists ($dest & "\image_" & $count & ".jpg") = 0
    Endif
DllCall(@tempdir & "\captdll.dll", "int", "CaptureScreen", "str", $dest & "\image_" & $count & ".jpg", "int", 100)

$count +=1
EndFunc

Func Quit()
$ans = MsgBox (262145, "Screen Capture", "Files are saved in " & $dest & @CRLF & "Do you really want to quit?")
If $ans = 1 then Exit
EndFunc

Func OnAutoITExit()
FileDelete (@tempdir & "\captdll.dll")
EndFunc
Link to comment
Share on other sites

Am I missing something, or is this just the same as doing...

Send("{PRINTSCREEN}") ; add alt, if required.

no?

-mu

That's WinKey + PrintScreen.

Nope, it aint the same. That copies the screenshot to the clipboard. It does not save it.

#)

Link to comment
Share on other sites

Dear LazyCat,

I have two question :

1) Is the all Dynamic Link Libraries ( DLL's ) located in this link www.autoitscript.com/fileman/users/Lazycat/dlls.html owned by you and you have All Copyrights.

2) If the all Dynamic Link Libraries ( DLL's ) located in this link www.autoitscript.com/fileman/users/Lazycat/dlls.htm owned by you and you have All Copyrights, Can I use and distribute it with the Autoit Scripts I created and/or Compiled Scripts and/or any Applications created for Personal use and Commercial use to sell the Scripts I created and/or Compiled Scripts and/or my Applications for profit or distribute it commercially or freely or for any purpose ?.

And do I have to pay any royalties or other fees to you or anyone if I use and distribute it with the Scripts I created and/or Compiled Scripts and/or Applications created for Personal use and Commercial as I explained before?.

Thanks to you in advance.

Best regards

H.J.

Edited by H.J.
Link to comment
Share on other sites

I made another screen capture app to go with LazyCats dll

#include <GuiConstants.au3>

;only allow 1 running copy
$g_szVersion = "MultiScreenDump"
If WinExists($g_szVersion) Then Exit MsgBox(262144, "Error", "Screen Capture is already running")
AutoItWinSetTitle($g_szVersion)

;install Dll
FileInstall("captdll.dll", @TempDir & "\captdll.dll", 1)

;set initial global settings
Global $count = 1, $dest = @ScriptDir, $quality = "100", $ext = "JPG" , $useButtonGui = 0

;instructions for user
MsgBox(262144, "Screen Capture", "Press ""F1"" to change settings at any time" & @CRLF & _
        "Press ""PrintScreen"" to capture whole screen" & @CRLF & _
        "Press ""Alt"" + ""Printscreen"" to capture active window" & @CRLF & _
        "Press ""escape"" to quit")

;bring up settings dialogue and activate hotkeys
Settings()


While 1
    If $usebuttonGui = 1 then ButtonGui()
    Sleep(100)
WEnd

Func Settings()
    
    HotKeySet("{PRINTSCREEN}", "Capture")
    HotKeySet("!{PRINTSCREEN}", "AreaCapture")
    HotKeySet("{ESC}", "Quit")
    HotKeySet("{F1}", "Settings")
    
    $main = GUICreate("Close this window to change settings", 392, 178, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
    $outputLabel = GUICtrlCreateLabel("Output Directory", 10, 15, 180, 20)
    $OutputDir = GUICtrlCreateInput("", 10, 40, 290, 25)
    GUICtrlSetData(-1, $dest)
    $Browse = GUICtrlCreateButton("Browse", 320, 40, 60, 25)
    $Combo = GUICtrlCreateCombo("JPG", 20, 75, 80, 61)
    GUICtrlSetData(-1, "BMP", $ext)
    
    $QualitySlide = GUICtrlCreateSlider(10, 100, 290, 30)
    GUICtrlSetLimit($QualitySlide, 100, 1)
    GUICtrlSetData($QualitySlide, $quality)
    
    If $ext = "BMP" then GuiCtrlSetState ($QualitySlide, $GUI_Disable)
    
    $SliderLabel = GUICtrlCreateLabel("Quality " & $quality, 200, 80, 120, 20)
    
    
    $OSButtons = GUICtrlCreateCheckbox ("Use on screen capture buttons", 20,150)
    If $useButtonGui = 1 then GuiCtrlSetState ($OSButtons, $GUI_CHECKED)
    
    GUISetState()
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                $dest = GUICtrlRead($OutputDir)
                If StringRight($dest, 1) = "\" Then $dest = StringTrimRight($dest, 1)
                $quality = GUICtrlRead($QualitySlide)
                $ext = GUICtrlRead($Combo)
                If Bitand (GUICtrlRead ($OSButtons), $GUI_Checked) Then 
                    $useButtonGui = 1
                Else 
                    $useButtonGui = 0
                    Endif
                GUIDelete($main)
                Exitloop
            Case $msg = $Browse
                $dest = FileSelectFolder("Select a destination", "", 1)
                GUICtrlSetData($OutputDir, $dest)
            Case $msg = $Combo
                If GUICtrlRead($Combo) = "BMP" Then
                    GUICtrlSetState($QualitySlide, $GUI_Disable)
                    GUICtrlSetData($SliderLabel, "Quality N/A")
                    $quality = "-1"
                    $ext = "BMP"
                Else
                    GUICtrlSetState($QualitySlide, $GUI_Enable)
                    $quality = GUICtrlRead($QualitySlide)
                    GUICtrlSetData($SliderLabel, "Quality " & $quality)
                EndIf
                
            Case $msg = $QualitySlide
                $quality = GUICtrlRead($QualitySlide)
                GUICtrlSetData($SliderLabel, "Quality " & $quality)
                $ext = "JPG"
                
            Case Else
                ;;;
        EndSelect
    WEnd
    ;Exit
EndFunc   ;==>Settings

Func ButtonGui()
$buttonGui = GuiCreate("Buttons", 120, 120,@DesktopWidth -170, @desktopheight -210 , $WS_POPUP, $WS_EX_TOPMOST)
$button1 = GuiCtrlCreateButton ("Screen",0,0,60,60)
$button2 = GuiCtrlCreateButton ("Area",61,0,60,60)
$button3 = GuiCtrlCreateButton ("Setup",0,61,60,60)
$button4 = GuiCtrlCreateButton ("Quit",61,61,60,60)
GuiSetState()

While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button1
        WinSetState ($buttonGui,"",@SW_MINIMIZE)
        GuiSetState (@SW_HIDE, $buttonGui)
        Capture()
        Sleep (100)
        GuiSetState (@SW_SHOW, $buttonGui)
        WinSetState ($buttonGui,"",@SW_Restore)
    Case $msg = $Button2
        WinSetState ($buttonGui,"",@SW_MINIMIZE)
        GuiSetState (@SW_HIDE, $buttonGui)
        AreaCapture()
        Sleep (100)
        GuiSetState (@SW_SHOW, $buttonGui)
        WinSetState ($buttonGui,"",@SW_Restore)
    Case $msg = $Button3
        GuiDelete($buttonGui)
        Send ("{F1}")
        ExitLoop
    Case $msg = $Button4
        Send ("{ESC}")
    Case Else
        If not BitAnd (WinGetState ($buttonGui),8) then WinSetOnTop ($buttonGui,"",1)
        ;;;
    EndSelect
WEnd
EndFunc


Func Capture()
    If FileExists($dest & "\image_" & $count & "." & $ext) <> 0 Then
        Do
            $count += 1
        Until FileExists($dest & "\image_" & $count & "." & $ext) = 0
    EndIf
    
    DllCall(@TempDir & "\captdll.dll", "int", "CaptureScreen", "str", $dest & "\image_" & $count & "." & $ext, "int", $quality)
    
    $count += 1
EndFunc   ;==>Capture

Func AreaCapture()
    
    If FileExists($dest & "\image_" & $count & "." & $ext) <> 0 Then
        Do
            $count += 1
        Until FileExists($dest & "\image_" & $count & "." & $ext) = 0
    EndIf
    
    $winlist = WinList()
    For $i = 1 To $winlist[0][0]
        $state = WinGetState($winlist[$i][1])
        If BitAND($state, 8) Then
            $cords = WinGetPos($winlist[$i][1])
            ExitLoop
        EndIf
        
    Next
    
    
    If IsArray($cords) Then
        DllCall(@TempDir & "\captdll.dll", "int", "CaptureRegion", "str", $dest & "\image_" & $count & "." & $ext, "int", $cords[0], "int", $cords[1], "int", $cords[2], "int", $cords[3], "int", $quality)
        $count += 1
    EndIf
    
EndFunc   ;==>AreaCapture

Func Quit()
    $ans = MsgBox(262145, "Screen Capture", "Files are saved in " & $dest & @CRLF & "Do you really want to quit?")
    If $ans = 1 Then Exit
EndFunc   ;==>Quit

Func OnAutoITExit()
    FileDelete(@TempDir & "\captdll.dll")
EndFunc   ;==>OnAutoITExit
Edited by ChrisL
Link to comment
Share on other sites

Dear LazyCat,

Please any replay to my two questions, I need your help and advice.

Best regards

H.J.

I'm not too experienced in licensing mazes, sorry :">

Dll is opensource, parts are used:

- Libjpeg v6 from Independent Jpeg Group (http://www.ijg.org/)

- bitmap to jpeg conversion routines written by magma (http://www.cppfrance.com/codes/BMP-JPG_28263.aspx)

You may check those sources, if they are allow commercial distribution. If this ok, nothing opposite from my side.

Link to comment
Share on other sites

.

The dll works great and is simple to use. I would like to capture the screen and paste the image into a button control with

GUICtrlSetImage ($controlID, "C:\ScreenShot001.bmp")

But the screenshot taken with the dll is too big. Could you add in the dll an option to freely resize the screenshot before saving the file?

Then, I have a *stupid* question, I am just wondering. Imagine that a window is full screen (not maximized though) and then you slide this window left by 100 pixels. Obviously, you cannot see the left part of the window anymore (I am assuming single monitor here). Then use the dll with CaptureRegion, passing -100 for x. The area returned is correct in size, but the 100pixels on the left are returned black.

I was just wondering whether it was possible that the dll returned what is actually left of the screen, in this case the original window.

I am asking this because I extensively use moving windows beyond the screen area (using WinMove) and want to get screenshots of what is outside of the screen.

PS: Why is it necessary to pass "int" parameters before passing x, y, etc.?

.

Link to comment
Share on other sites

.

Lookup DLLCall() in the help file.

Sorry, my download consists of the dll and an .au3 file only, I could not see any help file.

Lazycat, would you consider adding "image resizing" in your dll?

More generally, could anybody tell me how to put the huge bmp file created by Lazycat's dll inside a button control? I tried

GUICtrlSetImage ($controlID, "C:\ScreenShot001.bmp"),

but this shows just the part of the bmp image fitting the button dimension. I could not fit the whole screenshot inside a small button control.

.

Link to comment
Share on other sites

.

Sorry, i mean DLLCall() in the AutoIt help file.

#)

I see, but help file says that type is [optional]. Does the dll support passing nothing instead of "int"? It would be nice not to have to pass optional arguments. I do not see added-value passing "int".

.

Link to comment
Share on other sites

I used this code:

DllCall("captdll.dll", "int", "CaptureRegion", "str", "second_screen.jpg", "int", 1280, "int", 0, "int", 1280, "int", 1024, "int", 85)

to get a shot of my second monitor. Is there a more generic way to do this? How can I get the resolution of the 2nd screen and is relative location to the first screen (ie is it to the left or to the right of the 1st screen)?

Thanks,

-John

Edited by jftuga
Link to comment
Share on other sites

Cool!!!

An idea for a next version... It would be really neat if one could capture screens or regions of a non active or background window.

I just read your reply to H.J.'s post regarding distribution, and I'd like to say that if I use this dll for commercial purposes or otherwise I will make sure you have the respective credits. Thanks again for such a nice tool!

IVAN

Edited by ivan
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...