Jump to content

Screenshot dll is SLOW, is there a faster way?


Recommended Posts

Ive made this little script witch take a screenshot, and shows it in the gui. But i wanted it to update it as fast a possible, but even when doing it ecery 1 sec, it eats all the RAM by filling them up, and using alot of cpu time, can i somehow do this faster?

#Include <GUIConstants.au3>

Fileinstall("captdll.dll","captdll.dll",1)
Global $n

GUICreate("Screen Capture",400,400)
$Button = GUICtrlCreateButton("Take Screenshot",50,330,100,22)
$Label = GUICtrlCreateLabel("- - ",50,360,70,20)

$Dll = DllOpen("captdll.dll")
$Picname = "SS_Full.jpg"
GUISetstate()
While 1
    $Msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    
    If $Msg = $Button Then  
        $x = 1
        While 1
            Sleep(1000)
            GUICtrlSetdata($Label,$x)
            GUICtrlDelete($n)
            DllCall($Dll, "int", "CaptureScreen", "str", $Picname, "int", 80)
            $n=GUICtrlCreatePic($Picname,0,0,300,300)
        ;GUICtrlSetState($n, $GUI_DISABLE) 
            $n=GUICtrlSetPos($n,0,0,395,320)
            $x = $x+1
        WEnd
    EndIf
WEnd

ScreenshotGUI.exe

Link to comment
Share on other sites

First of all, you have error in you script: you assign $n=GUICtrlSetPos($n,0,0,395,320), so in next cycle $n is not control ID anymore, so you not delete control -> RAM full. Anyway, no need to delete control, GUICtrlSetImage do work better.

CPU usage you can reduce if you have use bmp instead jpg. Jpg is cpu intensive thing.

#Include <GUIConstants.au3>

Fileinstall("captdll.dll","captdll.dll",1)
Global $n

GUICreate("Screen Capture",400,400)
$Button = GUICtrlCreateButton("Take Screenshot",50,330,100,22)
$Label = GUICtrlCreateLabel("- - ",50,360,70,20)

$Dll = DllOpen("captdll.dll")
$Picname = "SS_Full.jpg"
DllCall($Dll, "int", "CaptureScreen", "str", $Picname, "int", 80); Create first pic
$n=GUICtrlCreatePic($Picname,0,0,395,320)

GUISetstate()
While 1
    $Msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    
    If $Msg = $Button Then    
        $x = 1
        While 1
            Sleep(500)
            GUICtrlSetdata($Label,$x)
            DllCall($Dll, "int", "CaptureScreen", "str", $Picname, "int", 80)
            GUICtrlSetImage($n, $Picname)
            GUICtrlSetPos($n,0,0,395,320)
            $x = $x+1
        WEnd
    EndIf
WEnd
Edited by Lazycat
Link to comment
Share on other sites

Have you tried Lazycat's ScreenShot DLL script to see if its any faster? Link is on the bottom of his sig.

Edit: I must sound like an idiot! I didn't even see Lazycat's post lol. I guess I just read the first post and replied lol.

Edited by Burrup

qq

Link to comment
Share on other sites

You can - in third party app :( But this anyway will lose details and will not be much more clear. If application support filtering by one of resizing algorithms (bilinear, bicubic, lanczos etc) you will get better quality, but most likely not satisfied by speed...

Link to comment
Share on other sites

You can - in third party app :( But this anyway will lose details and will not be much more clear. If application support filtering by one of resizing algorithms (bilinear, bicubic, lanczos etc) you will get better quality, but most likely not satisfied by speed...

<{POST_SNAPBACK}>

hmm, is there another way to make the pic smaller or easier to see :(
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...