Tripoz Posted July 23, 2015 Share Posted July 23, 2015 (edited) hi...i have the code like this :--edited--how to make my code running "Bacapayout()" func 1st..and then it will wait /stop looping until the @Min condition is TRUE and running the "SPOTakhir()" ??if @Min NOT TRUE it will wait till TRUE. n doing nothing (neither while loop) Edited August 11, 2015 by Tripoz Link to comment Share on other sites More sharing options...
JohnOne Posted July 23, 2015 Share Posted July 23, 2015 bacapayout() Do Sleep(1000) ;ContinueLoop Until @MIN = "02" Or @MIN = "15" Or @MIN = "25" Or @MIN = "35" Or @MIN = "45" Or @MIN = "58" SPOTakhir() AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Tripoz Posted July 23, 2015 Author Share Posted July 23, 2015 (edited) THX @JohnOne..btw, how to make if i wanna press Button1 once but it will loop endlessly what in inside. While 1 If @error then _scriptrestart() $nMsg = GUIGetMsg() Select case $nMsg = $Button1 bacapayout() Do sleep(1000) ;ContinueLoop Until @Min = "28" or @Min = "20" or @Min = "30" or @Min = "40" or @Min = "50" or @Min = "58" Then SPOTAkhir() Case $nMsg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Edited July 23, 2015 by Tripoz Link to comment Share on other sites More sharing options...
JohnOne Posted July 23, 2015 Share Posted July 23, 2015 I don't understand the question, you should also post a small runnable script to demonstrate your problem. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Tripoz Posted July 24, 2015 Author Share Posted July 24, 2015 (edited) I don't understand the question, you should also post a small runnable script to demonstrate your problem.i've posted above..thats my script.i want to run my GUI..after i Click button1 a.k.a "RUN" it will run Bacapayout() & spotakhir() (if the @MIN is True).the problem is, the code only loop 1 time and must clicking the button again to run it again.i want to make my code is only 1 Click and it will loop everything.if the code i change like this :--edited--if @min condition is not true. it will loop only in Bacapayout over and over...i dont want my code like this. Edited August 11, 2015 by Tripoz Link to comment Share on other sites More sharing options...
AutoBert Posted July 24, 2015 Share Posted July 24, 2015 This script crash's when running::\Users\Bert\AutoIt3.My\Test\asdf.au3" /UserParams +>16:32:39 Starting AutoIt3Wrapper v.14.801.2025.0 SciTE v.3.4.4.0 Keyboard:00000407 OS:WIN_81/ CPU:X64 OS:X64 Environment(Language:0407) +> SciTEDir => C:\Program Files\AutoIt3\SciTE UserDir => C:\Users\Bert\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\Bert\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.12.0) from:C:\Program Files\AutoIt3 input:C:\Users\Bert\AutoIt3.My\Test\asdf.au3 "C:\Users\Bert\AutoIt3.My\Test\asdf.au3"(6,25) : warning: $Button1: possibly used before declaration. case $nMsg = $Button1 ~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Users\Bert\AutoIt3.My\Test\asdf.au3"(13,105) : error: syntax error Until @Min = "28" or @Min = "20" or @Min = "30" or @Min = "40" or @Min = "50" or @Min = "58" Then ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Users\Bert\AutoIt3.My\Test\asdf.au3"(16,33) : warning: $GUI_EVENT_CLOSE: possibly used before declaration. Case $nMsg = $GUI_EVENT_CLOSE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Users\Bert\AutoIt3.My\Test\asdf.au3"(6,25) : error: $Button1: undeclared global variable. case $nMsg = $Button1 ~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Users\Bert\AutoIt3.My\Test\asdf.au3"(16,33) : error: $GUI_EVENT_CLOSE: undeclared global variable. Case $nMsg = $GUI_EVENT_CLOSE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Users\Bert\AutoIt3.My\Test\asdf.au3"(3,31) : error: _scriptrestart(): undefined function. If @error then _scriptrestart() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Users\Bert\AutoIt3.My\Test\asdf.au3"(8,22) : error: bacapayout(): undefined function. bacapayout() ~~~~~~~~~~~~~~~~~~~~~^ "C:\Users\Bert\AutoIt3.My\Test\asdf.au3"(14,22) : error: SPOTAkhir(): undefined function. SPOTAkhir() ~~~~~~~~~~~~~~~~~~~~~^ C:\Users\Bert\AutoIt3.My\Test\asdf.au3 - 6 error(s), 2 warning(s) !>16:32:39 AU3Check ended. Press F4 to jump to next error.rc:2 +>16:32:40 AutoIt3Wrapper Finished. >Exit code: 2 Time: 1.232so please post a runable script Link to comment Share on other sites More sharing options...
kylomas Posted July 24, 2015 Share Posted July 24, 2015 Tripoz,You are not getting much response to your thread because:1 - Your code is not runnable.2 - You descriptions are vague, possibly because English is not your native language.It appears that you are trying to create a message loop to run a set of functions both by timer (@MIN) and on demand. If this is a message loop the following construct is an example of one way to do this:expandcollapse popup#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <date.au3> Local $gui010 = GUICreate('Test',200,100) Local $Button1 = GUICtrlCreateButton('Run Functions On Demand', 10, 10, 180,80) GUISetState() local $iSaveMin While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $Button1 ConsoleWrite('! ---------- Manual Run' & @CRLF) bacapayout() SPOTAkhir() Case $nMsg = $GUI_EVENT_CLOSE Exit EndSelect switch @MIN case 41,42,43,44,46,40,50,58 if $iSaveMin <> @MIN then ConsoleWrite('! ---------- Timer Run' & @CRLF) bacapayout() SPOTAkhir() $iSaveMin = @MIN endif endswitch WEnd func bacapayout() ConsoleWrite(_now() & ' I just ran bacapayout()' & @CRLF) endfunc func SPOTAkhir() ConsoleWrite(_now() & ' I just ran SPOTAkhir()' & @CRLF) endfunc Note - This is an example demonstrating a programming paradigm only. You will have to apply it to your particular situation. Also, it is not necessary to use sleep() in a message loop because AutoIt idles the loop for you automatically.If this is not a message loop then the same principles apply except that you will have to idle the loop.kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Tripoz Posted July 26, 2015 Author Share Posted July 26, 2015 (edited) @kylomashi..sorry for late reply...im on my vacation. n Yes english is not my native language...i have runable code like this :#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <date.au3> Local $gui010 = GUICreate('Test',200,100) Local $Button1 = GUICtrlCreateButton('Run Functions On Demand', 10, 10, 180,80) GUISetState() while 1 bacapayout() sleep(1000) Do Until @MIN = "05" Or @MIN = "15" Or @MIN = "25" Or @MIN = "35" Or @MIN = "45" Or @MIN = "55" SPOTakhir() WEnd func bacapayout() ConsoleWrite(_now() & ' I just ran bacapayout()' & @CRLF) endfunc func SPOTAkhir() ConsoleWrite(_now() & ' I just ran SPOTAkhir()' & @CRLF) endfuncif i run it, the result is :if this time is Min 5,15,25,35,45,55 it will running Bacapayout() and Spotakhir() over and over again until @Min is False.when i ran it in @Min = False.,the result is it will ran bacapayout() only and wait till @Min is True..n doiing like above.That i want is It will RUnning Bacapayout() no matter the @min is true or False just once ,,,n it will running Spotakhir() only if @Min condition is TRUE.the 2nd question is :because i must run it from $Button1 (pressed 1 time in beggining) how can i looping (endless Loop) it without pressing that button over and over again?are my question clear??sorry for my bad english btw Edited July 26, 2015 by Tripoz Link to comment Share on other sites More sharing options...
kylomas Posted July 26, 2015 Share Posted July 26, 2015 (edited) Tripoz,The code you posted cannot be what you are running because:1 - You are not getting messages with GuiGetMsg()2 - Your do...until loop is not doing anything.3 - You are running both of your functions every 1 second. Your gui is entirely unresponsive.That i want is It will RUnning Bacapayout() no matter the @min is true or False just onceYou can run Bacapayout() just once by placing in front of the message loop (or your main loop).because i must run it from $Button1Run what from $Button1?Another version based on what I understand of your description...expandcollapse popup#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <date.au3> Local $gui010 = GUICreate('Test',200,100) GUISetState() local $iSaveMin ; this var is used to make sure that the func is run once for each minute that tests true bacapayout() While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit EndSelect switch @MIN case 05, 15, 25, 35, 45 if $iSaveMin <> @MIN then ConsoleWrite('! ---------- Timer Run' & @CRLF) SPOTAkhir() $iSaveMin = @MIN endif endswitch WEnd func bacapayout() ConsoleWrite(_now() & ' I just ran bacapayout()' & @CRLF) endfunc func SPOTAkhir() ConsoleWrite(_now() & ' I just ran SPOTAkhir()' & @CRLF) endfunckylomas Edited July 26, 2015 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Tripoz Posted July 27, 2015 Author Share Posted July 27, 2015 (edited) ==edited---Thx @kylomas Thats ur last code is what i mean.But how to combine in to Button1(Gui mode)... So the entire script will run over n over again(endless loop) if push the Button1??1 button click to endless loop the whole code.Thx Edited August 11, 2015 by Tripoz Link to comment Share on other sites More sharing options...
kylomas Posted July 27, 2015 Share Posted July 27, 2015 Tripoz,You do not endlessly loop the whole code. That is pretty much what the message loop is. I think you mean that you want to loop on the case statement for @MIN.The following will do this with control to stop this loop when you want.If this is not what you need then I believe that you have been given enough to puzzle out you own solution. Just read the Help file for parts that are not clear.expandcollapse popup#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <date.au3> Local $gui010 = GUICreate('Test', 200, 100) Local $cStart = GUICtrlCreateButton('Start', 10, 10, 180, 80) GUICtrlSetFont(-1, 24) GUISetState() Local $iSaveMin ; this var is used to make sure that the func is run once for each minute that tests true bacapayout() While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $cStart GUICtrlSetData($cStart, (GUICtrlRead($cStart) = 'Stop' ? 'Start' : 'Stop')) EndSelect If GUICtrlRead($cStart) = 'Stop' Then _Driver() WEnd Func _Driver() Switch @MIN Case 05, 15, 25, 35, 45 If $iSaveMin <> @MIN Then ConsoleWrite('! ---------- Timer Run' & @CRLF) SPOTAkhir() $iSaveMin = @MIN EndIf EndSwitch EndFunc ;==>_Driver Func bacapayout() ConsoleWrite(_Now() & ' I just ran bacapayout()' & @CRLF) EndFunc ;==>bacapayout Func SPOTAkhir() ConsoleWrite(_Now() & ' I just ran SPOTAkhir()' & @CRLF) EndFunc ;==>SPOTAkhirkylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Tripoz Posted July 27, 2015 Author Share Posted July 27, 2015 (edited) --edited-- Edited August 11, 2015 by Tripoz Link to comment Share on other sites More sharing options...
kylomas Posted July 27, 2015 Share Posted July 27, 2015 (edited) Tripoz,If that is what you want then good job. But your solution begs the question "why use a gui at all?" since the gui is completely useless after you start your loop. I would encourage you to try my last solution and work through it to understand what I am doing.Good Luck,kylomasedit: your code also does NOT test for specific minutes... Edited July 27, 2015 by kylomas additional info Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
guinness Posted July 27, 2015 Share Posted July 27, 2015 Also Dim has its uses, this is not one of them. Plus declaring variables inside a loop decreases performance, but pfff, who cares about that!? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 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