Jump to content

[Retracted][Resolved] Running code (timer dependant) - PixelChecksum doesnt work


 Share

Recommended Posts

EDIT:

I have created this code i basically makes a timer

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1 = GUICreate("Form1", 633, 447, 337, 137)
$Label1 = GUICtrlCreateLabel("Label1", 64, 32, 36, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$num = 1

While 1
    $nMsg = GUIGetMsg()
    
    $num += 1
    sleep(60)
    
    GUICtrlSetData($Label1, $num)
    
    If $num = 120 Then
        msgbox(0, "num", $num)
        $num = 1
    EndIf
    
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

since sleep() is in miliseconds i can simply sleep for 60 every loop (1 second) and then when the $num variable reached 120 it has been two seconds. this can be modified just an example.

--------------------------------------------------------------------------

Hi i have added lots to my current project today and have come accross a little problem, here is an example script that has been simplified to show you what im doing.

#include <GUIConstantsEx.au3>
   #include <StaticConstants.au3>
   #include <WindowsConstants.au3>
   #include <ScreenCapture.au3>
   
   #Region ### START Koda GUI section ### Form=
   $Resize_Factor = 2;2-6, 2=half size, 6=thumbnail image.
   $DT_Width = (@DesktopWidth / $Resize_Factor)
   $DT_Height = (@DesktopHeight / $Resize_Factor)
   $Form1 = GUICreate("Screen Cap", $DT_Width, $DT_Height)
   $Pic1 = GUICtrlCreatePic(".\test.jpg", 0, 0, $DT_Width, $DT_Height, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
   GUISetState(@SW_SHOW)
   #EndRegion ### END Koda GUI section ###
   
   While 1
       $nMsg = GUIGetMsg()
       _ScreenCapture_Capture(".\test.jpg", 0, 0, @DesktopWidth, @DesktopHeight, True)
       GUICtrlSetImage($Pic1, ".\test.jpg")
       Switch $nMsg
           Case $GUI_EVENT_CLOSE
               Exit
       EndSwitch
   WEnd

it doesnt matter that it is screenshotting the same computers screen that is just an example.

what i am trying to do is display an image on my gui which is updated constantly and needs to be show, the problem is whenever i use _ScreenCapture_Capture the program lags and i am unable to use most of the controlls on my form like buttons etc.

what i was wondering is there a way to delay the screen capture without halting the rest of the program, or is there an alternative to this method which would be faster.

Thanks

FaT3oYCG

Edited by FaT3oYCG

Interpreters have great power!Although they live in the shadow of compiled programming languages an interpreter can do anything that a compiled language can do, you just have to code it right.

Link to comment
Share on other sites

Do capture only if something changes:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ScreenCapture.au3>

Global $crc, $crc_prev

#Region ### START Koda GUI section ### Form=
$Resize_Factor = 2;2-6, 2=half size, 6=thumbnail image.
$DT_Width = (@DesktopWidth / $Resize_Factor)
$DT_Height = (@DesktopHeight / $Resize_Factor)
$Form1 = GUICreate("Screen Cap", $DT_Width, $DT_Height)
$Pic1 = GUICtrlCreatePic(".\test.jpg", 0, 0, $DT_Width, $DT_Height, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
     $nMsg = GUIGetMsg()

    $crc = PixelChecksum(0, 0, @DesktopWidth, @DesktopHeight)
    If $crc <> $crc_prev Then
        _ScreenCapture_Capture(".\test.jpg", 0, 0, @DesktopWidth, @DesktopHeight, True)
      GUICtrlSetImage($Pic1, ".\test.jpg")
        $crc_prev = $crc
    EndIf

     Switch $nMsg
         Case $GUI_EVENT_CLOSE
             Exit
     EndSwitch
WEnd
Link to comment
Share on other sites

XD didnt think of that and didnt know about the pixel checksum function, thanks that seems logical enough.

I really have to say the help on these forums is most excelent cheers.

EDIT:

hmm that doesnt seem to work because of the mouse? even if i tell the mouse not to display in the screenshot it will still change the checksum of the screen

EDIT 2:

I've updated the first post i have found a solution, basically i have created a timer like i wanted to.

Edited by FaT3oYCG

Interpreters have great power!Although they live in the shadow of compiled programming languages an interpreter can do anything that a compiled language can do, you just have to code it right.

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...