Carlos_Wendel Posted October 15, 2021 Posted October 15, 2021 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.
Moderators Melba23 Posted October 15, 2021 Moderators Posted October 15, 2021 Moved to the appropriate forum. Moderation Team 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Moderators Melba23 Posted October 15, 2021 Moderators Posted October 15, 2021 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Zedna Posted October 15, 2021 Posted October 15, 2021 (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 October 15, 2021 by Zedna fixed reset to X=1 from X_MAX Resources UDF ResourcesEx UDF AutoIt Forum Search
Carlos_Wendel Posted October 15, 2021 Author Posted October 15, 2021 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!
Zedna Posted October 15, 2021 Posted October 15, 2021 (edited) In script from Melba is just missing declaration of File UDF (at top of script) : #include <File.au3> Edited October 15, 2021 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now