Jump to content

Recommended Posts

Posted

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

Posted (edited)

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
Posted (edited)

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

Posted

Okay its working much better now, thanks... but the image i put in my GUI is very blur, its because it have been scaled down right? Can i rezise it so it would be much more clear to see whats on the pic?

Posted

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 :(

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
×
×
  • Create New...