Jump to content

Capturing a screenshot at a certain time, need help!


Recommended Posts

#include <GUIConstants.au3>
#include <Array.au3>

global $msg, $checkright, $quit, $inhalt1

GUICreate("Capture a screenshot at a certain time", 400, 100,10,10)

CreateGui()
GUISetState()  ; display the GUI
Window()
MainLoop()

Func Window()
    Do

        $msg = GUIGetMsg()
        Select
            Case $msg= $GUI_EVENT_CLOSE
                MsgBox(0, "HU", "Good bye")
                $quit = 1
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE
    
EndFunc

Func API_GetLocalTime()
    Local $stSystemTime = DllStructCreate('ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort')
    DllCall('kernel32.dll', 'none', 'GetLocalTime', 'ptr', DllStructGetPtr($stSystemTime))
   
    Local $gst=DllStructGetData($stSystemTime, 5)
    For $i = 6 to 6
        $gst = $gst & ":" & DllStructGetData($stSystemTime, $i)
    Next
   
    $stSystemTime = 0 ; free structure from memory
    return $gst
EndFunc

Func CreateGui()
    $checkright = GUICtrlCreateCheckbox ("Activated", 30, 10)
    $inhalt1 = GUICtrlCreateInput (API_GetLocalTime(), 250, 30, 100)
    $SRL = GUICtrlCreateLabel("Time to take screenshot:", 70, 30, 200)
    GUICtrlSetFont($SRL,9,600)
EndFunc

Func MainLoop()
    Do
        if(GUICtrlRead($checkright)=1) Then
            if(API_GetLocalTime()=GUICtrlRead($inhalt1)) Then
            $hPlugin = PluginOpen(@scriptdir & "\captplugin.dll")
            CaptureScreen("Bottat.bmp", 100)
            PluginClose($hPlugin)
            EndIf
        endif
    Until $quit = "1"
EndFunc

Credits to the ones who made the other functions I use, but what am I doing wrong since this ONLY takes a screenshot when I CLOSE the program :<

Link to comment
Share on other sites

#include <GUIConstants.au3>
#include <Array.au3>

global $msg, $checkright, $quit, $inhalt1

GUICreate("Capture a screenshot at a certain time", 400, 100,10,10)

CreateGui()
GUISetState() ; display the GUI
Window()
MainLoop()

Func Window()
    Do
        $msg = GUIGetMsg()
        Select
            Case $msg= $GUI_EVENT_CLOSE
                MsgBox(0, "HU", "Good bye")
                $quit = 1
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE
EndFunc

Func API_GetLocalTime()
    Local $stSystemTime = DllStructCreate('ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort')
    DllCall('kernel32.dll', 'none', 'GetLocalTime', 'ptr', DllStructGetPtr($stSystemTime))
   
    Local $gst=DllStructGetData($stSystemTime, 5)
    For $i = 6 to 6
        $gst = $gst & ":" & DllStructGetData($stSystemTime, $i)
    Next
   
    $stSystemTime = 0; free structure from memory
    return $gst
EndFunc

Func CreateGui()
    $checkright = GUICtrlCreateCheckbox ("Activated", 30, 10)
    $inhalt1 = GUICtrlCreateInput (API_GetLocalTime(), 250, 30, 100)
    $SRL = GUICtrlCreateLabel("Time to take screenshot:", 70, 30, 200)
    GUICtrlSetFont($SRL,9,600)
EndFunc

Func MainLoop()
    Do
        if(GUICtrlRead($checkright)=1) Then
            if(API_GetLocalTime()=GUICtrlRead($inhalt1)) Then
            $hPlugin = PluginOpen(@scriptdir & "\captplugin.dll")
            CaptureScreen("Bottat.bmp", 100)
            PluginClose($hPlugin)
            EndIf
        endif
    Until $quit = "1"
EndFunc

Credits to the ones who made the other functions I use, but what am I doing wrong since this ONLY takes a screenshot when I CLOSE the program :<

That's because MainLoop() is never executed until Window() returns. And Window() does not return until the GUI is closed. Either you need to combine the two, or learn to use GuiOnEventMode.

:P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...