Jump to content
Sign in to follow this  
MariusN

timerinit in Tray-Section

Recommended Posts

MariusN

I have a function in the tray-section that gets executed every 2 secs...I noticed that the timer wont activate unless i move my mouse over the tray-icon...Is there some setting to overcome this?

thx guys...

Share this post


Link to post
Share on other sites
Melba23

MariusN,

You should know by now what we are going to say......"Show some code!" :(

You see, my crystal ball is at the repairers for a few days. :mellow:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
Fulano

MariusN,

You should know by now what we are going to say......"Show some code!" :lol:

You see, my crystal ball is at the repairers for a few days. :(

M23

Don't worry, you can borrow mine :mellow:

...

...

Uhhhh, where'd I put that thing?


#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Share this post


Link to post
Share on other sites
Melba23

Fulano,

Thanks for the offer, but on this side of the Atlantic I need a 240V model. :mellow:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
MariusN

...the "code" :mellow:

_tray()
Opt('MustDeclareVars', 1)
Opt("TrayMenuMode", 3)
Func _tray()
    Local $i_timer2, $test, $readtest, $MSG, $i_pid2, $s_stdout, $receive, $send, $var1, $rnd1, $rnd2, $rnd3, $rnd4, $var2
    Local $open1, $read8, $open4, $write2, $open5, $read9, $open2, $read2, $open3, $open1, $open6, $open7, $read10,$i_timer,$fileLog, $fileLog2,$view,$exititem
    Local $write1, $read1, $total1, $read4, $read3, $i_timer
    Local $ip_sec = 1

    $fileLog = (@ScriptDir & "\nrd3.txt")
    $fileLog2 = (@ScriptDir & "\total.log")
    $rnd3 = $rnd1 + $rnd2
$view = TrayCreateItem("View Live Feed")
$exititem = TrayCreateItem("Exit")
Opt('MustDeclareVars', 1)
Opt("TrayMenuMode", 3)

    TraySetState()
    While 1

        $MSG = TrayGetMsg()

        Select
            Case $MSG = 0
                ContinueLoop
            Case $MSG = $view
                ;_Start()
            Case $MSG = $exititem
                Exit
        EndSelect

        If TimerDiff($i_timer2) / 1000 >= 2 Then
            MsgBox(0, "", "timerdiff")
            $i_pid2 = Run(@ComSpec & " /c netstat -e", @SystemDir, @SW_HIDE, 6)
            While 1
                $s_stdout &= StdoutRead($i_pid2)
                If @error Then
                    ExitLoop
                EndIf
            WEnd

            If $s_stdout Then
                $receive = StringMid($s_stdout, 100, 17)
                $send = StringMid($s_stdout, 115, 17)
                $var1 = $receive / 1048576
                $rnd1 = Round($var1, 3)
                $var2 = $send / 1048576
                $rnd2 = Round($var2, 3)
                $rnd3 = $rnd1 + $rnd2

                ;==============================================================================================
                $open5 = FileOpen($fileLog2, 0)
                $read3 = FileReadLine($open5, 1)
                FileClose($open5)

                If $read1 = $rnd3 Then
                Else

                    $open1 = FileOpen($fileLog, 0)
                    $read1 = FileReadLine($open1, 1) ; Total1
                    FileClose($open1)

                    $open2 = FileOpen($fileLog, 2)
                    $write1 = FileWriteLine($open2, $rnd3) ;Total2
                    FileClose($open2)
                    $total1 = $rnd3

                    $open3 = FileOpen($fileLog2, 0)
                    $read2 = FileReadLine($open3, 1)
                    FileClose($open3)

                    $open4 = FileOpen($fileLog2, 2)
                    FileWriteLine($open4, $read2 + $rnd3 - $read1)
                    FileClose($open4)

                    $open6 = FileOpen($fileLog2, 0)
                    $read4 = FileReadLine($open6, 1)
                    FileClose($open6)

                EndIf
                $s_stdout = ""
                $i_timer2 = TimerInit()
                ;============================================================================================
            EndIf
        EndIf

    WEnd
EndFunc   ;==>_tray
Edited by MariusN

Share this post


Link to post
Share on other sites
Melba23

MariusN,

You need to define $i_timer2 BEFORE you start your loop and then you need to reset it each time it is called, not just when the If statement is true.

This runs every 2 seconds for me:

Opt('MustDeclareVars', 1)
Opt("TrayMenuMode", 3)

_tray()

Func _tray()
    Local $i_timer2, $test, $readtest, $MSG, $i_pid2, $s_stdout, $receive, $send, $var1, $rnd1, $rnd2, $rnd3, $rnd4, $var2
    Local $open1, $read8, $open4, $write2, $open5, $read9, $open2, $read2, $open3, $open1, $open6, $open7, $read10, $i_timer, $fileLog, $fileLog2, $view, $exititem
    Local $write1, $read1, $total1, $read4, $read3, $i_timer
    Local $ip_sec = 1

    $fileLog = (@ScriptDir & "\nrd3.txt")
    $fileLog2 = (@ScriptDir & "\total.log")
    $rnd3 = $rnd1 + $rnd2
    $view = TrayCreateItem("View Live Feed")
    $exititem = TrayCreateItem("Exit")

    ;Opt('MustDeclareVars', 1)  ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Why declare twice?
    ;Opt("TrayMenuMode", 3)

    TraySetState()

    $i_timer2 = TimerInit()

    While 1

        $MSG = TrayGetMsg()
        Select
            ;Case $MSG = 0
            ;   ContinueLoop
            Case $MSG = $view
                ;_Start()
            Case $MSG = $exititem
                Exit
        EndSelect

        If TimerDiff($i_timer2) / 1000 >= 2 Then
            MsgBox(0, "", "timerdiff")
            #cs
            $i_pid2 = Run(@ComSpec & " /c netstat -e", @SystemDir, @SW_HIDE, 6)
            While 1
                $s_stdout &= StdoutRead($i_pid2)
                If @error Then
                    ExitLoop
                EndIf
            WEnd

            If $s_stdout Then
                $receive = StringMid($s_stdout, 100, 17)
                $send = StringMid($s_stdout, 115, 17)
                $var1 = $receive / 1048576
                $rnd1 = Round($var1, 3)
                $var2 = $send / 1048576
                $rnd2 = Round($var2, 3)
                $rnd3 = $rnd1 + $rnd2

                ;==============================================================================================
                $open5 = FileOpen($fileLog2, 0)
                $read3 = FileReadLine($open5, 1)
                FileClose($open5)

                If $read1 = $rnd3 Then
                Else

                    $open1 = FileOpen($fileLog, 0)
                    $read1 = FileReadLine($open1, 1) ; Total1
                    FileClose($open1)

                    $open2 = FileOpen($fileLog, 2)
                    $write1 = FileWriteLine($open2, $rnd3) ;Total2
                    FileClose($open2)
                    $total1 = $rnd3

                    $open3 = FileOpen($fileLog2, 0)
                    $read2 = FileReadLine($open3, 1)
                    FileClose($open3)

                    $open4 = FileOpen($fileLog2, 2)
                    FileWriteLine($open4, $read2 + $rnd3 - $read1)
                    FileClose($open4)

                    $open6 = FileOpen($fileLog2, 0)
                    $read4 = FileReadLine($open6, 1)
                    FileClose($open6)

                EndIf
                $s_stdout = ""
                ;$i_timer2 = TimerInit() ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Remove from here
                ;============================================================================================
            EndIf
            #ce
            $i_timer2 = TimerInit() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  Add here
        EndIf

    WEnd
EndFunc   ;==>_tray

Look for the <<<<<<<<<<<<<< lines. :mellow:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
MariusN

thx Melba :mellow:

Weird that if a person code long hours, you start missing things ...lol

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.