Jump to content

how to Repeat The Timer ?


Recommended Posts

Hi,

I asked In Prev Topic How to Run Multiple Functions In The same Time And A User Editied My timer So it doesnt Interfer With Other Functions

Here's The Old TImer Function

Func _Timer()


    ; Variables
    $x1 = GUICtrlRead($List1) ; Timer In Minutes
    $Minutes = GUICtrlRead($Input2)
    Local $60Count = 0, $begin = TimerInit()


    While $Minutes > $60Count


        $dif = TimerDiff($begin)
        $dif2 = StringLeft($dif, StringInStr($dif, ".") - 1)
        $Count = Int($dif / 1000)
        $60Count = Int($Count / 60)
        ;*********************************************************************
        ; // This The Label Section \\ Start Here
        ;---------------------------------------------------------------------------------
        $Label6 = GUICtrlCreateLabel($Minutes, 280, 216, 33, 17)
        GUICtrlSetBkColor(-1, 0x00FF00)
        $Label7 = GUICtrlCreateLabel($60Count, 280, 244, 89, 20)
        GUICtrlSetBkColor(-1, 0x00FF00)
        $Label8 = GUICtrlCreateLabel($Count, 288, 268, 65, 20)
        GUICtrlSetBkColor(-1, 0x00FF00)
        $Status2 = GUICtrlCreateLabel("Working", 168, 168, 45, 17)
        GUICtrlSetBkColor(-1, 0x00FF00)
        $Label4 = GUICtrlCreateLabel($x1, 296, 167, 45, 17)
        ;---------------------------------------------------------------------------------
        ; // The Label section Ends Here \\ Ends Here
        ;********************************************************************

        Sleep(200)
        
    WEnd
    If $Minutes = $60Count Then Call("_Save")
EndFunc   ;==>_Timer



Func _Save()
    $x1 = GUICtrlRead($List1)
    $x2 = ("[CLASS:" & $x1 & "]")
    
    If WinActive($x2) Then
        Sleep(200)
        Send("^s")
        TrayTip("AutoSaver", "The AutoSaver Just Made A save In " & $x1, 10)
        Call("_Timer")
        
    ElseIf WinWaitActive($x2) Then
        Sleep(500)
        Send("^s")
        TrayTip("AutoSaver", "The AutoSaver Just Made A save In " & $x1, 10)
        Call("_Timer")


    EndIf
EndFunc   ;==>_Save

So The Old One Worked Like Charm And It Had An infinite loop (When The timer Finishes It Repeats Itself By Calling The Function "_Timer" Back)

 

Here is The New One

$Label6 = GUICtrlCreateLabel("", 280, 216, 33, 17)        ;You should use Guictrlsetdata instead of creating new labels
        GUICtrlSetColor(-1, 0x00FF00)
        $Label7 = GUICtrlCreateLabel("", 280, 244, 89, 20)
        GUICtrlSetColor(-1, 0x00FF00)
        $Label8 = GUICtrlCreateLabel("", 288, 268, 65, 20)
        GUICtrlSetColor(-1, 0x00FF00)
        $Status2 = GUICtrlCreateLabel("", 168, 168, 45, 17)
        GUICtrlSetColor(-1, 0x00FF00)
        $Label4 = GUICtrlCreateLabel("", 296, 167, 45, 17)
        
        
        
    AdlibRegister("_Timer", 200)    ;Call this function every 250ms
    ; Variables
    $x1 = GUICtrlRead($List1) ; Timer In Minutes
    
    Global $minutes , $Dif , $Count  
    
    $Minutes = GUICtrlRead($Input2)

    Static  $60Count = 0, $begin = TimerInit()       ;Use static on variables that should retain its value


    If  $Minutes > $60Count      Then ;No loop until timer completes


        $dif = TimerDiff($begin)
        $dif2 = StringLeft($dif, StringInStr($dif, ".") - 1)
        $Count = Int($dif / 1000)
        $60Count = Int($Count / 60)
        ;*********************************************************************
        ; // This The Label Section \\ Start Here
        ;---------------------------------------------------------------------------------
       $MinLabel = GUICtrlSetData($Label6 , $Minutes)
       $Seclabel = GUICtrlSetData($Label7 , $60Count)
       $TimLabel = GUICtrlSetData($Label8 , $Count)
       $StatusLabel = GUICtrlSetData ($Status2 , "Working")
       $Tim2Label = GUICtrlSetData ($label4 , $x1 )    
        ;---------------------------------------------------------------------------------
        ; // The Label section Ends Here \\ Ends Here
        ;********************************************************************
EndIf 
    If $Minutes = $60Count Then
Call("_Save")
UnAdlibRegister("_Timer")
    EndIf

EndFunc   ;==>_Timer



Func _Save()
    $x1 = GUICtrlRead($List1)
    $x2 = ("[CLASS:" & $x1 & "]")
    
    If WinActive($x2) Then
        Sleep(200)
        Send("^s")
        TrayTip("AutoSaver", "The AutoSaver Just Made A save In " & $x1, 10)
        Call("_Timer")
        
    ElseIf WinWaitActive($x2) Then
        Sleep(500)
        Send("^s")
        TrayTip("AutoSaver", "The AutoSaver Just Made A save In " & $x1, 10)
        Call("_Timer")


    EndIf
EndFunc   ;==>_Save

How can i repeat The Function Of The Timer After It Finishes :D ..... Sorry for my bad English

Link to comment
Share on other sites

While 1;<== This will loop the program forever
  _Timer()
WEnd
  
Func _Timer()
        
        $Label6 = GUICtrlCreateLabel("", 280, 216, 33, 17)        ;You should use Guictrlsetdata instead of creating new labels
        GUICtrlSetColor(-1, 0x00FF00)
        $Label7 = GUICtrlCreateLabel("", 280, 244, 89, 20)
        GUICtrlSetColor(-1, 0x00FF00)
        $Label8 = GUICtrlCreateLabel("", 288, 268, 65, 20)
        GUICtrlSetColor(-1, 0x00FF00)
        $Status2 = GUICtrlCreateLabel("", 168, 168, 45, 17)
        GUICtrlSetColor(-1, 0x00FF00)
        $Label4 = GUICtrlCreateLabel("", 296, 167, 45, 17)
        
        
        
    AdlibRegister("_Timer", 200)    ;Call this function every 250ms
    ; Variables
    $x1 = GUICtrlRead($List1) ; Timer In Minutes
    
    Global $minutes , $Dif , $Count  
    
    $Minutes = GUICtrlRead($Input2)

    Static  $60Count = 0, $begin = TimerInit()       ;Use static on variables that should retain its value


    If  $Minutes > $60Count      Then ;No loop until timer completes


        $dif = TimerDiff($begin)
        $dif2 = StringLeft($dif, StringInStr($dif, ".") - 1)
        $Count = Int($dif / 1000)
        $60Count = Int($Count / 60)
        ;*********************************************************************
        ; // This The Label Section \\ Start Here
        ;---------------------------------------------------------------------------------
       $MinLabel = GUICtrlSetData($Label6 , $Minutes)
       $Seclabel = GUICtrlSetData($Label7 , $60Count)
       $TimLabel = GUICtrlSetData($Label8 , $Count)
       $StatusLabel = GUICtrlSetData ($Status2 , "Working")
       $Tim2Label = GUICtrlSetData ($label4 , $x1 )    
        ;---------------------------------------------------------------------------------
        ; // The Label section Ends Here \\ Ends Here
        ;********************************************************************
EndIf 
    If $Minutes = $60Count Then
Call("_Save")
UnAdlibRegister("_Timer")
    EndIf

EndFunc   ;==>_Timer



Func _Save()
    $x1 = GUICtrlRead($List1)
    $x2 = ("[CLASS:" & $x1 & "]")
    
    If WinActive($x2) Then
        Sleep(200)
        Send("^s")
        TrayTip("AutoSaver", "The AutoSaver Just Made A save In " & $x1, 10)
        Call("_Timer")
        
    ElseIf WinWaitActive($x2) Then
        Sleep(500)
        Send("^s")
        TrayTip("AutoSaver", "The AutoSaver Just Made A save In " & $x1, 10)
        Call("_Timer")


    EndIf
EndFunc   ;==>_Save

It looks like you only provided some of your code. What is above this snippet of code? Is it Func _Timer()? - I assume that it is and I changed it to reflect that assumption.

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

Here Is The Whole Code :D

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>
#include <GUIListBox.au3>
#include <File.au3>
#include <StaticConstants.au3>
#include <Timers.au3>

Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)
Opt("TrayMenuMode", 3)
Opt("TrayOnEventMode", 1)
#region ### START Koda GUI section ### Form=
GLobal $Form1 = GUICreate("TheBlackAutoSaver", 651, 373, 257, 171)
$program = GUICtrlCreateLabel("program:", 230, 166, 88, 23)
$Timer = GUICtrlCreateLabel("Timer", 96, 56, 44, 23)
$Input1 = GUICtrlCreateInput("", 552, 8, 81, 21)
$Input2 = GUICtrlCreateInput("", 144, 56, 97, 21)
$Start = GUICtrlCreateButton("Start", 176, 320, 121, 25)
GUICtrlSetOnEvent(-1, 'start')
$Add = GUICtrlCreateButton("Add", 496, 8, 49, 25)
GUICtrlSetOnEvent(-1, 'add')
$Delete = GUICtrlCreateButton("Delete", 496, 40, 137, 25)
GUICtrlSetOnEvent(-1, 'Delete')
$Group1 = GUICtrlCreateGroup("Timer", 96, 152, 281, 145, BitOR($GUI_SS_DEFAULT_GROUP, $WS_BORDER))
$Status = GUICtrlCreateLabel("Status:", 120, 168, 40, 17)
GUICtrlSetTip(-1, "The Status")
$Label1 = GUICtrlCreateLabel("TImer", 120, 216, 76, 17)
$Label2 = GUICtrlCreateLabel("Minutes Passed", 120, 248, 76, 17)
$Label3 = GUICtrlCreateLabel("seconds", 120, 272, 76, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton(" Add From ProccessList ", 504, 344, 121, 25)
GUICtrlSetOnEvent(-1, 'hPList')
$Label9 = GUICtrlCreateLabel("Times Saved : ", 8, 344, 75, 17)
GUISetState(@SW_SHOW)
$Contex1 = GUICtrlCreateContextMenu()
Local $Chide = GUICtrlCreateMenuItem("Hide", $Contex1)
GUICtrlSetOnEvent(-1, 'Hide')
GUICtrlCreateMenuItem("", $Contex1)
Local $idMenuOpen = GUICtrlCreateMenuItem("Exit", $Contex1)
GUICtrlSetOnEvent(-1, '_Exit')
TraySetIcon("C:\Users\SuPeRBiGMaC\Downloads\1406157282_27876.ico", -1)
Local $TrayExit = TrayCreateItem("Show")
TrayItemSetOnEvent(-1, '_Show')
Local $TrayShow = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, 'Exit1')
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
$Pic1 = GUICtrlCreatePic("C:\Users\SuPeRBiGMaC\Downloads\1406157497_46-facebook.jpg", 0, 128, 25, 25)
GUICtrlSetOnEvent(-1 , 'fb')
$Pic2 = GUICtrlCreatePic("C:\Users\SuPeRBiGMaC\Downloads\1406157783_43-twitter.jpg", 0, 160, 25, 25)
GUICtrlSetOnEvent(-1 , 'Twit')
#endregion ### END Koda GUI section ###
; -------------------\\  Loader // ---------------------------- |  Starts  |
Global $File = @WorkingDir & "\App.txt"
Local $iFileExists = FileExists($File)
Global $List1 = GUICtrlCreateList("", 488, 72, 145, 266)

If $iFileExists Then
    ;$file = "C:\Users\SuPeRBiGMaC\Desktop\Autosave\Test.txt"
    FileOpen($File, 0)
    ;$List1 = GUICtrlCreateList("", 496, 72, 145, 279)
    For $i = 1 To _FileCountLines($File)
        $line = FileReadLine($File, $i)
        GUICtrlSetData($List1, $line & "|")
    Next
    FileClose($File)
Else
    _FileCreate($File)

EndIf
HotKeySet("{ESC}", "_Terminate")


While 1

Sleep(500)
 
WEnd

; ------------------------- \\ List Loader // --------------------- |  Ends  |
Func Exit1()
    Exit
EndFunc   ;==>Exit1

Func Close()
Exit
EndFunc

Func _Show()
    GUISetState(@SW_SHOW)
EndFunc   ;==>_Show

Func Hide()
    GUISetState(@SW_HIDE)
    TrayTip("AutoSaver", "Dont Worry , Iam Still Here :D ", 10)
EndFunc   ;==>Hide

Func _Exit()
    Exit
EndFunc   ;==>_Exit



Func AddP()
    $Plist = GUICtrlRead($list2)
    $x1 = StringTrimRight($Plist, 4)
    GUICtrlSetData($List1, $x1 & "|")
    GUIDelete()
    FileOpen($File, 0)
    FileWrite($File, $x1 & @CRLF)
    FileClose($File)
EndFunc   ;==>AddP

Func fb()
    ShellExecute("https://www.facebook.com/Super.Mas.7")
EndFunc   ;==>fb

Func twit()
    ShellExecute("https://twitter.com/AnwerMac")
EndFunc   ;==>twit
Func hPlist()
    $Form2 = GUICreate("Form1", 266, 455, 446, 218)
    Global $List2 = GUICtrlCreateList("", 56, 24, 145, 370)
    $ButtonP = GUICtrlCreateButton("Add", 56, 416, 129, 25)
    GUICtrlSetOnEvent(-1, 'AddP')
    GUISetState(@SW_SHOW)

    $hPlist = ProcessList()

    For $i = 1 To $hPlist[0][0]
        GUICtrlSetData($List2, $hPlist[$i][0])
    Next

    If $hPlist[0][0] = 0 Then MsgBox("", "", "Proccess List equal 0 ")
EndFunc   ;==>hPlist
;                                                                                                                   ------------------- \\ Functions Area // ------------------------

; ----------------------Timer Function Starts Here \\ Start  //-----------------
Func Add()
    $Add = GUICtrlRead($Input1)
    ;$file = "C:\Users\SuPeRBiGMaC\Desktop\Autosave\Test.txt"
    $hFileOpen = FileOpen($File, 0)
    $hFileWrite = _FileCountLines($File)
    $hLine = $hFileWrite + 1
    FileWrite($File, $Add & @CRLF)
    FileClose($File)
    GUICtrlSetData(-1, $Add & "|")
EndFunc   ;==>Add
; ------------------------------------------------------------------
Func Delete()
    $x1 = GUICtrlRead($List1)
    _GUICtrlListBox_DeleteString($List1, _GUICtrlListBox_GetCaretIndex($List1))
    Dim $aRecords
    ;$file = "C:\Users\SuPeRBiGMaC\Desktop\Autosave\Test.txt"
    $hFileOpen = FileOpen($File, 0)
    _FileReadToArray($File, $aRecords)
    For $x = 1 To $aRecords[0]
        If StringInStr($aRecords[$x], $x1) Then
            _FileWriteToLine($File, $x, "", 1)
        EndIf
    Next
    FileClose($File)
EndFunc   ;==>Delete

Func _Timer()
        
        
        $Label6 = GUICtrlCreateLabel("", 280, 216, 33, 17)        ;You should use Guictrlsetdata instead of creating new labels
        GUICtrlSetColor(-1, 0x00FF00)
        $Label7 = GUICtrlCreateLabel("", 280, 244, 89, 20)
        GUICtrlSetColor(-1, 0x00FF00)
        $Label8 = GUICtrlCreateLabel("", 288, 268, 65, 20)
        GUICtrlSetColor(-1, 0x00FF00)
        $Status2 = GUICtrlCreateLabel("", 168, 168, 45, 17)
        GUICtrlSetColor(-1, 0x00FF00)
        $Label4 = GUICtrlCreateLabel("", 296, 167, 45, 17)
        
        
        
    AdlibRegister("_Timer", 200)    ;Call this function every 250ms
    ; Variables
    $x1 = GUICtrlRead($List1) ; Timer In Minutes
    
    Global $minutes , $Dif , $Count  
    
    $Minutes = GUICtrlRead($Input2)

    Static  $60Count = 0, $begin = TimerInit()       ;Use static on variables that should retain its value


    If  $Minutes > $60Count      Then ;No loop until timer completes


        $dif = TimerDiff($begin)
        $dif2 = StringLeft($dif, StringInStr($dif, ".") - 1)
        $Count = Int($dif / 1000)
        $60Count = Int($Count / 60)
        ;*********************************************************************
        ; // This The Label Section \\ Start Here
        ;---------------------------------------------------------------------------------
       $MinLabel = GUICtrlSetData($Label6 , $Minutes)
       $Seclabel = GUICtrlSetData($Label7 , $60Count)
       $TimLabel = GUICtrlSetData($Label8 , $Count)
       $StatusLabel = GUICtrlSetData ($Status2 , "Working")
       $Tim2Label = GUICtrlSetData ($label4 , $x1 )    
        ;---------------------------------------------------------------------------------
        ; // The Label section Ends Here \\ Ends Here
        ;********************************************************************
EndIf 
    If $Minutes = $60Count Then
Call("_Save")
UnAdlibRegister("_Timer")
    EndIf

EndFunc   ;==>_Timer
;-----------------------------\\ Timer Ends Here // ------------------------------


Func Test ()
If $Minutes  = $60Count Then 
$Dif = 0 
EndIf
EndFunc 

Func _Terminate()
    Exit
EndFunc   ;==>_Terminate
; --------------------

Func Start()

    $x1 = GUICtrlRead($List1)
    $x2 = GUICtrlRead($Input2)

    If $List1 = "" Or $x2 = "" Then
        MsgBox("", "", "Error , Please Check That U Enter A value In The Timer InputBox  , Or That u have Selected  a Program ! ")
    ElseIf ProcessExists($x1 & ".exe") Then
        ;GUISetState(@SW_HIDE)
        Call("_Timer")

    Else
        MsgBox("", "", "The Program must Be Runnig for The Autosaver to work ")
    EndIf

EndFunc   ;==>Start



Func _Save()
    $x1 = GUICtrlRead($List1)
    $x2 = ("[CLASS:" & $x1 & "]")

    If WinActive($x2) Then
        
        Send("^s")
        TrayTip("AutoSaver", "The AutoSaver Just Made A save In " & $x1, 10)
         AdlibRegister("_Timer")
        Call("_Timer")

    ElseIf WinWaitActive($x2) Then
   
        Send("^s")
        TrayTip("AutoSaver", "The AutoSaver Just Made A save In " & $x1, 10)
         AdlibRegister("_Timer")
        call("_Timer")

        EndIf
EndFunc   ;==>_Save

I Just Wanted to Repeat The Timer

Link to comment
Share on other sites

My opinion is that your code is really quite a  mess. You have at lease 4 separate functions spread all over the script that Exit the program. Your script also has a commend that is supposed to identify where the Functions start and there are several functions above and below it. Typically when I make a program I will format it like this:

1. Include files. Ex. #include <MsgBoxConstants.au3>

2. Global variables and HotKeySet items. Ex. Global TimerInit()

3. Stuff that need to run before I run my main loop. Ex. Deleting any temporary files left over from the scripts last run and recreating them for use this run.

4. The main while loop if there is one and a list of functions that I want to run in a certain order. I also like to comment them for later use and for things like asking for help on the autoit forums. Ex:

While 1

     Hide();Hides the GUI window

     AddP();Adds a person to a text file for later use

     fb();Open Facebook

     twit();Open Twitter

     hPlist();Makes a GUI with controls for...

     Add();sub function of hPlist

     Delete();another sub function of hPlist

WEnd

5. Then all of your functions. ex:

Func Exit1()
    Exit
EndFunc   ;==>Exit1

Func Close()
Exit
EndFunc

Func _Exit()
    Exit
EndFunc   ;==>_Exit

Func _Terminate()
    Exit
EndFunc   ;==>_Terminate

BTW these are all from your script and they all do the same thing with different function calls. Its messy and unnecessary.

This way we can better understand what the program does. If I were to guess I would do this (4th and 5th line from the bottom):

$Label6 = GUICtrlCreateLabel("", 280, 216, 33, 17)        ;You should use Guictrlsetdata instead of creating new labels
        GUICtrlSetColor(-1, 0x00FF00)
        $Label7 = GUICtrlCreateLabel("", 280, 244, 89, 20)
        GUICtrlSetColor(-1, 0x00FF00)
        $Label8 = GUICtrlCreateLabel("", 288, 268, 65, 20)
        GUICtrlSetColor(-1, 0x00FF00)
        $Status2 = GUICtrlCreateLabel("", 168, 168, 45, 17)
        GUICtrlSetColor(-1, 0x00FF00)
        $Label4 = GUICtrlCreateLabel("", 296, 167, 45, 17)
        
        
 Func _Timer()       
    AdlibRegister("_Timer", 200)    ;Call this function every 250ms
    ; Variables
    $x1 = GUICtrlRead($List1) ; Timer In Minutes
    Global $minutes , $Dif , $Count  
    $Minutes = GUICtrlRead($Input2)
    Static  $60Count = 0, $begin = TimerInit()       ;Use static on variables that should retain its value

    If  $Minutes > $60Count      Then ;No loop until timer completes
        $dif = TimerDiff($begin)
        $dif2 = StringLeft($dif, StringInStr($dif, ".") - 1)
        $Count = Int($dif / 1000)
        $60Count = Int($Count / 60)
        ;*********************************************************************
        ; // This The Label Section \\ Start Here
        ;---------------------------------------------------------------------------------
       $MinLabel = GUICtrlSetData($Label6 , $Minutes)
       $Seclabel = GUICtrlSetData($Label7 , $60Count)
       $TimLabel = GUICtrlSetData($Label8 , $Count)
       $StatusLabel = GUICtrlSetData ($Status2 , "Working")
       $Tim2Label = GUICtrlSetData ($label4 , $x1 )    
        ;---------------------------------------------------------------------------------
        ; // The Label section Ends Here \\ Ends Here
        ;********************************************************************
    EndIf 

    If $Minutes = $60Count Then
    Call("_Save")
        Sleep(250)<= To maintain the 250 ms according to your comments but it appears like yours is set to 200
    AdlibRegister("_Timer");<= I think you meant AdlibUnregister("_Timer") but I just changed it to AdlibRegister because its just being reregistered
    EndIf

EndFunc   ;==>_Timer

Try it and report back.

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

My opinion is that your code is really quite a  mess. You have at lease 4 separate functions spread all over the script that Exit the program. Your script also has a commend that is supposed to identify where the Functions start and there are several functions above and below it. Typically when I make a program I will format it like this:

1. Include files. Ex. #include <MsgBoxConstants.au3>

2. Global variables and HotKeySet items. Ex. Global TimerInit()

3. Stuff that need to run before I run my main loop. Ex. Deleting any temporary files left over from the scripts last run and recreating them for use this run.

4. The main while loop if there is one and a list of functions that I want to run in a certain order. I also like to comment them for later use and for things like asking for help on the autoit forums. Ex:

While 1

     Hide();Hides the GUI window

     AddP();Adds a person to a text file for later use

     fb();Open Facebook

     twit();Open Twitter

     hPlist();Makes a GUI with controls for...

     Add();sub function of hPlist

     Delete();another sub function of hPlist

WEnd

5. Then all of your functions. ex:

Func Exit1()
    Exit
EndFunc   ;==>Exit1

Func Close()
Exit
EndFunc

Func _Exit()
    Exit
EndFunc   ;==>_Exit

Func _Terminate()
    Exit
EndFunc   ;==>_Terminate

BTW these are all from your script and they all do the same thing with different function calls. Its messy and unnecessary.

This way we can better understand what the program does. If I were to guess I would do this (4th and 5th line from the bottom):

$Label6 = GUICtrlCreateLabel("", 280, 216, 33, 17)        ;You should use Guictrlsetdata instead of creating new labels
        GUICtrlSetColor(-1, 0x00FF00)
        $Label7 = GUICtrlCreateLabel("", 280, 244, 89, 20)
        GUICtrlSetColor(-1, 0x00FF00)
        $Label8 = GUICtrlCreateLabel("", 288, 268, 65, 20)
        GUICtrlSetColor(-1, 0x00FF00)
        $Status2 = GUICtrlCreateLabel("", 168, 168, 45, 17)
        GUICtrlSetColor(-1, 0x00FF00)
        $Label4 = GUICtrlCreateLabel("", 296, 167, 45, 17)
        
        
 Func _Timer()       
    AdlibRegister("_Timer", 200)    ;Call this function every 250ms
    ; Variables
    $x1 = GUICtrlRead($List1) ; Timer In Minutes
    Global $minutes , $Dif , $Count  
    $Minutes = GUICtrlRead($Input2)
    Static  $60Count = 0, $begin = TimerInit()       ;Use static on variables that should retain its value

    If  $Minutes > $60Count      Then ;No loop until timer completes
        $dif = TimerDiff($begin)
        $dif2 = StringLeft($dif, StringInStr($dif, ".") - 1)
        $Count = Int($dif / 1000)
        $60Count = Int($Count / 60)
        ;*********************************************************************
        ; // This The Label Section \\ Start Here
        ;---------------------------------------------------------------------------------
       $MinLabel = GUICtrlSetData($Label6 , $Minutes)
       $Seclabel = GUICtrlSetData($Label7 , $60Count)
       $TimLabel = GUICtrlSetData($Label8 , $Count)
       $StatusLabel = GUICtrlSetData ($Status2 , "Working")
       $Tim2Label = GUICtrlSetData ($label4 , $x1 )    
        ;---------------------------------------------------------------------------------
        ; // The Label section Ends Here \\ Ends Here
        ;********************************************************************
    EndIf 

    If $Minutes = $60Count Then
    Call("_Save")
        Sleep(250)<= To maintain the 250 ms according to your comments but it appears like yours is set to 200
    AdlibRegister("_Timer");<= I think you meant AdlibUnregister("_Timer") but I just changed it to AdlibRegister because its just being reregistered
    EndIf

EndFunc   ;==>_Timer

Try it and report back.

 

I Know The Code Is a Mess :D

First Project ... After Fixing This I Re-Coded So i can Re-arrange The Functions :D

 

The Edit U did Made The Code Repeat The Save Function Not tHe TImer

Link to comment
Share on other sites

How about this:

    If $Minutes = $60Count Then
    Call("_Save")
    Static $60Count = 0, $begin = TimerInit(); Reset this variable should be like restarting the function
    EndIf

Does this work?

I compiled this script and fixed a few errors I was getting and it compiled. What is it supposed to do? What program do you want to use this for?

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

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