RobReijm Posted July 25, 2015 Share Posted July 25, 2015 (edited) Hi Guys,I`m new at AutoIT, so excuse me if my quistions are explained detailled enough.I have a question:I`m writing a bit of code that does the following:It reads a value from my com port, this can be 0 or <> 0, what I want is that the value changes from 0 to <> 0 or from <>0 to 0 my slideshow resizes its format.So, basicly I have a slideshow running conitnuasly based on files in a folder. THese jpg files should all be shown 5 seconds and than the next image.but when the value is change it should directly change it screen size.Now I have this code, is there someone who can help me finish this last bit:expandcollapse popup#include <GUIConstants.au3> #include <File.au3> #include <Array.au3> #include "CommInterface.au3" #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #region - Settings HotKeySet("{ESC}", "Terminate") Opt("WinTitleMatchMode", 3) #endregion ;GUISetBkColor(0xE0FFFF) If @error Then Return SetError(@error, @ScriptLineNumber) $picarray = _FileListToArray("C:\Users\Rob\Desktop\SaBjoTi\Photos\") Local $sString = "This is an example of writing to the console." ConsoleWrite($sString & @CRLF) ; Running this in a text editor which can trap console output e.g. SciTE, will display value of $sString. ;$gui = GUICreate("SlideshowLarge",@DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP) ;$pic = GUICtrlCreatePic("C:\Users\Rob\Desktop\SaBjoTi\"& $picarray[1], 0, 0, @DesktopWidth, @DesktopHeight) $gui = GUICreate("Slideshow",250, 250, 0, 0, $WS_POPUP) $pic = GUICtrlCreatePic("C:\Users\Rob\Desktop\SaBjoTi\Photos\"& $picarray[1], 0, 0, 250, 250) GUISetCursor(16,1) GUISetState() ;$picarray = _FileListToArray("C:\Users\Rob\Desktop\SaBjoTi\Photos\") Local $hFile = _CommAPI_OpenCOMPort(7, 9600, 0, 8, 1) Local $sResult = "10" Func Slideshow () $picarray = _FileListToArray("C:\Users\Rob\Desktop\SaBjoTi\Photos\") ;Sleep(5000) Do For $n = 1 To $picarray[0] GUICtrlSetImage($pic, "C:\Users\Rob\Desktop\SaBjoTi\Photos\" & $picarray[$n]) Sleep (5000) Next Until @error EndFunc ; Slideshow () While True $sResult = _CommAPI_ReceiveString($hFile, 5000) ; MsgBox($MB_SYSTEMMODAL, "", "Value of $i is: " & $sResult) If $sResult = 0 then ;MsgBox($MB_SYSTEMMODAL, "", "result is 0: " & $sResult) GUICtrlSetPos($Pic, 150, 150, 300, 300) Do $sResult = _CommAPI_ReceiveString($hFile, 5000) For $n = 1 To $picarray[0] GUICtrlSetImage($pic, "C:\Users\Rob\Desktop\SaBjoTi\Photos\" & $picarray[$n]) ; Sleep (5000) Next Until $sResult > 50 ElseIf $sResult > 50 then ;MsgBox($MB_SYSTEMMODAL, "", "result is 0: " & $sResult) GUICtrlSetPos($Pic, 0, 0, 100, 100) Do For $n = 1 To $picarray[0] GUICtrlSetImage($pic, "C:\Users\Rob\Desktop\SaBjoTi\Photos\" & $picarray[$n]) $sResult = _CommAPI_ReceiveString($hFile, 5000) Sleep (1000) $sResult = _CommAPI_ReceiveString($hFile, 5000) Sleep (1000) $sResult = _CommAPI_ReceiveString($hFile, 5000) Sleep (1000) $sResult = _CommAPI_ReceiveString($hFile, 5000) Sleep (1000) Next Until $sResult = 0 EndIf WEndHope to hear from somebody. GreetzRob Edited July 25, 2015 by Melba23 Added code tags Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 25, 2015 Moderators Share Posted July 25, 2015 RobReijm,Welcome to the AutoIt forums.When you post code please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags.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 Link to comment Share on other sites More sharing options...
RobReijm Posted July 25, 2015 Author Share Posted July 25, 2015 Thanks Melba, Will do!! Link to comment Share on other sites More sharing options...
RobReijm Posted July 27, 2015 Author Share Posted July 27, 2015 I`m testing with an other script, I am able to switch the size of the images from small to full screen. But at soon as I add this line of code into a function: For $n = 1 To $picarray[0] GUICtrlSetImage($pic, "C:\Users\Rob\Desktop\SaBjoTi\Photos\" & $picarray[$n]) Sleep (5000) NextThe loop waits untill this loop is done. So i`m not able to directly switch from a big to small screen.This is my complete code:expandcollapse popup#include <GUIConstantsEx.au3> #include <Constants.au3> #include <GUIConstants.au3> #include <File.au3> #include <Array.au3> #include "CommInterface.au3" $picarray = _FileListToArray("C:\Users\Rob\Desktop\SaBjoTi\Photos\") $gui = GUICreate("SlideshowLarge",@DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP) $pic = GUICtrlCreatePic("C:\Users\Rob\Desktop\SaBjoTi\Photos\"& $picarray[1], 0, 0, @DesktopWidth, @DesktopHeight) $pic = GUISetBkColor(0x000000) GUISetCursor(16,1) GUISetState() ; Declare a flag Global $fRunOne = True Local $hFile = _CommAPI_OpenCOMPort(6, 9600, 0, 8, 1) Local $sResult = "10" Opt("GUIOnEventMode", 1) ;$hGUI = GUICreate("Test", 500, 500) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") ;$hButton_1 = GUICtrlCreateButton("Func One", 10, 10, 80, 30) ;$hButton_1 = "Func One" ;GUICtrlSetOnEvent($hButton_1, "_Func_1") ;$hButton_2 = "Func Two" ;GUICtrlSetOnEvent($hButton_2, "_Func_2") ; $hButton_3 = GUICtrlCreateButton("Func Three", 10, 90, 80, 30) ; $hButton_3 = "Func Three" ;GUICtrlSetOnEvent($hButton_3, "_Func_3") $picarray = _FileListToArray("C:\Users\Rob\Desktop\SaBjoTi\Photos\") GUISetState() ;_Func_1() _Func_2() While 1 Sleep(10) ; Check if the flag has been set by the OnEvent function If $fRunOne Then ; Now start the "real" function from within the main code _Func_1_Run() EndIf WEnd Func _Func_1() ; Set the flag within the OnEvent function $fRunOne = True For $n = 1 To $picarray[0] GUICtrlSetImage($pic, "C:\Users\Rob\Desktop\SaBjoTi\Photos\" & $picarray[$n]) Sleep (5000) Next EndFunc ;==>_Func_1 Func _Func_1_Run() GUICtrlSetPos($Pic, 0, 0, @DesktopWidth, @DesktopHeight) ; Slideshow () Global $fRunOne = False EndFunc ;==>_Func_1_Run Func _Func_2() GUICtrlSetPos($Pic, 0, 0, 100, 100) ;Slideshow () Do $sResult = _CommAPI_ReceiveString($hFile, 5000) Until $sResult > 50 _Func_3() EndFunc ;==>_Func_2 Func _Func_3() GUICtrlSetPos($Pic, 0, 0, @DesktopWidth, @DesktopHeight) Do $sResult = _CommAPI_ReceiveString($hFile, 5000) Until $sResult = 0 _Func_2() EndFunc ;==>_Func_2 Func _Exit() Exit EndFunc ;==>_ExitIs there anyone who can help me change the code so that the picture slideshow isn`t causing my script to pauze? thanks Link to comment Share on other sites More sharing options...
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