Jump to content

Recommended Posts

Posted

Hello, my friends.
I'm new to this forum and no programmer at all, so please have patience with my humble questions.
In our business, we have developed an extremely simple program with the purpose of reading all of the ".jpgs" in a folder one by one and splashing on a propaganda screen.
However, we have come to a limitation (human beings).

The program relies on reading files one by one in a sequence by name (1.jpg, 2.jpg, 3.jpg... etc).
If said sequence is broken by a distracted human being, the program is limited to return to one.

You may notice that some of the text below is in brazilian portuguese but the idiomatic difficulty is irrelevant to the question because the folder structure is correct.
 

$X=1

While 1

If FileExists ("\\192.168.0.171\propaganda\narita_barra\" & $X & ".jpg") Then
SplashImageOn ("", "\\192.168.0.171\propaganda\narita_barra\" & $X & ".jpg", @DesktopWidth, @DesktopHeight, default, default, 1)
Sleep (30000)
SplashOff ()
$X = $X+1
Else
$X=1
EndIf
Sleep (60000)


WEnd

I'm searching for suggestions to overcome the human problem so that the program can skip human mistakes (lack of sequential file names by number).
In case I didn't achieve making myself clear, it HAS to be 1.jpg, 2.jpg, etc.. else the program fails to read all files.

 

Correct Structure on a folder.png

Incorrect Structure on a folder.png

  • Moderators
Posted

Moved to the appropriate forum.

Moderation Team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • Moderators
Posted

Carlos_Wendel,

Welcome to the AutoIt forums.

You are approaching this the wrong way. Rather than depending on the correct naming of the files, simply use FileListToArray to list the .jpg files present into an array and then loop through the array. Something like this should work:

; Give an opportunity to quit the infinte loop!
HotKeySet("{ESC}", "_Exit")

; Read the files into the array
Global $aList = _FileListToArray("Your_Folder_Path", "*.jpg", $FLTA_FILES, True)

While 1
    ; Loop through the file list
    For $i = 1 To $aList[0]
        SplashImageOn("", $aList[$i], @DesktopWidth, @DesktopHeight, Default, Default, 1)
        Sleep(30000)
        SplashOff()
    Next
    Sleep(60000)
    ; And start again
WEnd

Func _Exit()
    Exit
EndFunc

Does that do the trick? Please ask if you have any questions.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (edited)

As Melba said.

Anyway here is corrected original script which skips missing images immediately without Sleep()

$X = 1
$X_MAX = 100

While 1
    If FileExists("\\192.168.0.171\propaganda\narita_barra\" & $X & ".jpg") Then
        SplashImageOn("", "\\192.168.0.171\propaganda\narita_barra\" & $X & ".jpg", @DesktopWidth, @DesktopHeight, Default, Default, 1)
        Sleep(30000)
        SplashOff()
        Sleep(60000)
    EndIf
    $X = $X + 1
    If $X = $X_MAX Then $X = 1
WEnd

 

Edited by Zedna
fixed reset to X=1 from X_MAX
Posted

Thank you for you help!
I found both are to be very elegant solutions.
I had difficulty with the array version, so I ended up with a prototype of a little from both options.

 

$X = 1
$X_MAX = 100

Func _Exit()
    Exit
EndFunc


HotKeySet("{ESC}", "_Exit")
HotKeySet("{Enter}", "_Exit")


While 1
    If FileExists("\\192.168.0.171\propaganda\narita_barra\" & $X & ".jpg") Then
        SplashImageOn("", "\\192.168.0.171\propaganda\narita_barra\" & $X & ".jpg", @DesktopWidth, @DesktopHeight, Default, Default, 1)
        Sleep(30000)
        SplashOff()
        Sleep(60000)
    EndIf
    $X = $X + 1
    If $X = $X_MAX Then $X = 1
WEnd

Seems to work like a charm. 

Thank you!
 

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