Jump to content

Continuous Naming


Recommended Posts

Hey,

I just need help to make this. Basically, you enter how many screenshots it takes, how long it sleeps for and where the pictures are saved to.

Using PaulIA's lib screen cap function I managed to make this:

Func _ScreenCap()
    $Captured = 1
    If Not FileExists($Data) Then
        $Screens = InputBox("Screen Capture", "How many times do you wish to capture the screen for?", "10")
        $Sleep = InputBox("Screen Capture", "Thankyou, how often do you wish to wait before another screenshot is take? (Seconds)", "1")
        $Location = FileSelectFolder("Where do you wish to save the screenshots?", @ScriptDir, 1)
        IniWrite($Data, "ScreenCapture", "Amount", $Screens)
        IniWrite($Data, "ScreenCapture", "Sleep", $Sleep)
        IniWrite($Data, "ScreenCapture", "Location", $Location)
    Else
        $Capt = IniReadSection($Data, "ScreenCapture")
        For $a = 1 To $Capt[0][0]
            Do 
                GUISetState(@SW_HIDE, $MainGUI)
                _ScreenCap_Capture(IniReadSection($Data, "Location" & $Capt[$a][$Screens] & ".jpg"))
                ConsoleWrite("Captured")
                $Captured += 1
                Sleep(IniReadSection($Data, "Sleep"))
            Until $Captured = IniReadSection($Data, "Amount")
        Next
        GUISetState(@SW_SHOW, $MainGUI)
    EndIf
EndFunc   ;==>_ScreenCap

What I need it to do is this:

  • Get how many times it takes a screenshot
  • How long it sleeps for between each shot
  • Where the files are saved to
Thanks,

James

Link to comment
Share on other sites

Prompt with InputBox() functions and a FileSelectFolder().

:rolleyes:

P.S. Errmm... all of which you already have in there. It doesn't work?

P.P.S. Your test for done is doomed because IniReadSection() returns an array:

; Until $Captured = IniReadSection($Data, "Amount")
          Until $Captured = IniRead($Data, "ScreenCapture", "Amount")

:rambo:

Edited by PsaltyDS
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

After trying it and having to add that extra number at the end I came up with:

Func _ScreenCap()
    $Data = @ScriptDir & '\db\data.ini'
    $Captured = 1
    If Not FileExists($Data) Then
        $Screens = InputBox("Screen Capture", "How many times do you wish to capture the screen for?", "10")
        $Sleep = InputBox("Screen Capture", "Thankyou, how often do you wish to wait before another screenshot is take? (Seconds)", "1")
        $Location = FileSelectFolder("Where do you wish to save the screenshots?", @ScriptDir, 1)
        IniWrite($Data, "ScreenCapture", "Amount", $Screens)
        IniWrite($Data, "ScreenCapture", "Sleep", $Sleep)
        IniWrite($Data, "ScreenCapture", "Location", $Location)
    Else
        $Capt = IniReadSection($Data, "ScreenCapture")
        For $a = 1 To $Capt[0][0]
            Do 
                GUISetState(@SW_HIDE, $MainGUI)
                _ScreenCap_Capture(IniReadSection($Data, "Location" & $Capt[$a][$Screens] & ".jpg"))
                ConsoleWrite("Captured")
                $Captured += 1
                Sleep(IniReadSection($Data, "Sleep"))
            Until $Captured = IniRead($Data, "ScreenCapture", "Amount", 10)
        Next
        GUISetState(@SW_SHOW, $MainGUI)
    EndIf
EndFunc   ;==>_ScreenCap

But that doesnt work either :rolleyes:

Link to comment
Share on other sites

After trying it and having to add that extra number at the end I came up with:

But that doesnt work either :rambo:

This tweaks it so the function continues after the operator inputs values to create a new ini, and adds some error checking.

The next part is commented out because it makes no sense without a sample of the ini file. You seem to be reading the wrong section, or using IniReadSection where IniRead is all you need. Can't figure it out without the ini file sample.

Func _ScreenCap()
    $Data = @ScriptDir & '\db\data.ini'
    $Captured = 1
    If Not FileExists($Data) Then
        ; Get settings from operator and save to .ini
        $Screens = InputBox("Screen Capture", "How many times do you wish to capture the screen for?", "10")
        If @error Then Return 0
        $Sleep = InputBox("Screen Capture", "How often do you wish to wait between screenshots? (Seconds)", "1")
        If @error Then Return 0
        $Location = FileSelectFolder("Where do you wish to save the screenshots?", @ScriptDir, 1)
        If @error Then Return 0
        IniWrite($Data, "ScreenCapture", "Amount", $Screens)
        IniWrite($Data, "ScreenCapture", "Sleep", $Sleep)
        IniWrite($Data, "ScreenCapture", "Location", $Location)
    EndIf
    
    #cs
    $Capt = IniReadSection($Data, "ScreenCapture")
    If @error Or $Capt[0][0] = 0 Then
        Return 0
    Else
        For $a = 1 To $Capt[0][0]
            Do
                GUISetState(@SW_HIDE, $MainGUI)
                _ScreenCap_Capture (IniReadSection($Data, "Location" & $Capt[$a][$Screens] & ".jpg"))
                ConsoleWrite("Captured")
                $Captured += 1
                Sleep(IniReadSection($Data, "Sleep"))
            Until $Captured = IniRead($Data, "ScreenCapture", "Amount", 10)
        Next
        GUISetState(@SW_SHOW, $MainGUI)
    EndIf
    #ce
EndFunc   ;==>_ScreenCap

:rolleyes:

Edited by PsaltyDS
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

  • Moderators

That wouldn't do anything. Its comments, when the program is run, its like they are not there.

lol... not to bright are ya :rambo: ... the "Screen Capture" call is in the comments :rolleyes:

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Well there is no .ini file until it has been created, your way seems better, but no screenshots are taken :S

In that case, the first time you run it, an ini will be created formatted like this:

[ScreenCapture]
Amount=10
Sleep=3
Location=C:\Temp\Test

Now look at your following code. Why are you doing this?

$Capt = IniReadSection($Data, "ScreenCapture")

Again with the IniReadSection() instead of just IniRead().

You've been told this before. Read the help file on the commands you are trying to use. Study the difference between IniReadSection() and IniRead() until it sinks in...

:rolleyes:

Edited by PsaltyDS
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

  • Moderators

Yeah.. I have done, but I couldn't understand. Sorry.

You don't understand that IniReadSection() returns an Array there for you are probably going to need to display them in a "non" string manner... ie.. $aArray = IniReadSection(File,Section)

MsgBox(0, 0, $aArray[1][1]);Red is either [0] or [1] and represents Key and Value ... [0] = Key, [1] = Value.

Versus IniRead() returning a string, and could be used as MsgBox(0,0, IniRead(File,Section,Key,Alternate Value))?

As long as you've been here and 1800+ posts, if you don't understand that MAJOR difference between the two functions after "admitting" you've read them, then you should really give AutoIt up and take up checkers or 20 mile bike rides in much much higher altitudes.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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