Jump to content

RESOLVED Timer - Need a new set of eyes, as it does not allow new items...


nitekram
 Share

Recommended Posts

Trying to get this time to work - it should add a ticket to the array, along with time stamp info. It does this and when you remove the alert - they should go away and GUI should close - seems to work. But if I remove all ticket numbers and then try to add a ticket - nothing happens?

To use: click on icon for app. Click on times and add a ticket number (does not matter what you put here). Then view the tickets in a list. Check the checkbox to remove alert for list.

This code was pulled from working script - these are the main functions and this is runable in scite for testing purpose.

Thanks for anyone willing to look at this and see what I did or might be doing wrong.

#include <array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Date.au3>

Opt("TrayMenuMode", 3)

Global $aTimer[2], $aTimerCheck[2], $aTicketNumber[2], $aTicketStartTime[2], $iTimerCount = 0
Global $aShowAllStatus[UBound($aTimer)]
Global $timeKeeper = TimerInit()
Global $countingwhileloop = 0, $checkreturn = 1

Global $stimersitem = TrayCreateItem("Timer(s)")
Global $aDisplayItem = TrayCreateItem("DisplayArrayTimers)")
TrayCreateItem("")
Global $exititem = TrayCreateItem("Exit")

TraySetState()

Local $timer = 0
While 1
$Tray_msg = TrayGetMsg()

Select
Case $Tray_msg = $stimersitem
$checkreturn = CounterMessage($iTimerCount)
If $checkreturn <> -1 Then $iTimerCount += 1

Case $Tray_msg = $aDisplayItem
CheckTime('', True)
GUI_Escalation()

Case $Tray_msg = $exititem
Exit
EndSelect

$countingwhileloop += 1
CheckTime($countingwhileloop, False)
WEnd


Func GUI_Escalation() ; Escalation Manager
Local $CheckBoxAlerts[2]
Local $aDeleteAlert[2]
$Height = (UBound($aShowAllStatus) * 35) + 100

If UBound($aShowAllStatus) >= UBound($CheckBoxAlerts) Then
For $x = 0 To UBound($aShowAllStatus) - 1
_ArrayAdd($CheckBoxAlerts, '')
Next
EndIf

$GUI_Alerts = GUICreate('Escalation Manager', 350, $Height)

For $x = 0 To UBound($aShowAllStatus) - 1
If $aShowAllStatus[$x] <> '' Then
$CheckBoxAlerts[$x] = GUICtrlCreateCheckbox($aShowAllStatus[$x], 5, $x * 35)
EndIf
Next

$ButtonAlerts = GUICtrlCreateButton('Remove Alert', 200, $Height - 50, 100, 35)
GUISetState(@SW_SHOW) ; will display an empty dialog box

While 1
$msg_Escaltion = GUIGetMsg()
If $msg_Escaltion = $GUI_EVENT_CLOSE Then
GUISetState(@SW_HIDE)
GUIDelete()
ExitLoop
EndIf

If $msg_Escaltion = $ButtonAlerts Then
;MsgBox('','','button pressed')

For $x = 0 To UBound($aShowAllStatus) - 1
If BitAND(GUICtrlRead($CheckBoxAlerts[$x]), $GUI_CHECKED) = $GUI_CHECKED Then
;MsgBox('', 'checked', '$CheckBoxAlerts[$x] = ' & $CheckBoxAlerts[$x])

If $x >= UBound($aDeleteAlert) - 1 Then
ConsoleWrite('Adding Array element ' & $x & @CRLF)
_ArrayAdd($aDeleteAlert, $x)
;_ArrayDisplay($aDeleteAlert, 'added')
Else
ConsoleWrite('Array element ' & $x & @CRLF)
$aDeleteAlert[$x] = $x
;_ArrayDisplay($aDeleteAlert, 'not added')
EndIf
EndIf
Next
;_ArrayDisplay($aDeleteAlert, 'not sorted')
_ArraySort($aDeleteAlert, 1)
;_ArrayDisplay($aDeleteAlert, 'sorted')

For $y = UBound($aShowAllStatus) - 1 To 0 Step -1
;MsgBox('','$y',$y)

For $x = 0 To UBound($aDeleteAlert) - 1
;MsgBox('','$aDeleteAlert[$x]',$aDeleteAlert[$x])
If $y == $aDeleteAlert[$x] Then
;MsgBox('', '$y = ' & $aDeleteAlert[$x], 'match')
GUICtrlSetState($CheckBoxAlerts[$y], $GUI_HIDE)
GUICtrlSetState($CheckBoxAlerts[$y], $GUI_UNCHECKED)
_ArrayDelete($aShowAllStatus, $y)
_ArrayDelete($aTimer, $y)
_ArrayDelete($aTimerCheck, $y)
_ArrayDelete($aTicketNumber, $y)
_ArrayDelete($aTicketStartTime, $y)
$iTimerCount -= 1
ExitLoop
Else
;MsgBox('', 'NONENONENONE', 'match')
EndIf
Next
Next

GUISetState(@SW_HIDE)
GUIDelete()
ExitLoop

EndIf
WEnd

EndFunc ;==>GUI_Escalation
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func CounterMessage($iCount)
Local $TicketToTrack

$TicketToTrack = InputBox('Enter AMXXXXXXXX Ticket Number', 'Enter the ticket number to track!')

If @error Or $TicketToTrack = '' Then Return -1
If $iCount >= UBound($aTimer) Then
_ArrayAdd($aTimer, TimerInit())
_ArrayAdd($aTimerCheck, True)
_ArrayAdd($aTicketNumber, $TicketToTrack)
_ArrayAdd($aTicketStartTime, @HOUR & ':' & @MIN)
_ArrayAdd($aShowAllStatus, '')

Else
$aTimer[$iCount] = TimerInit()
$aTimerCheck[$iCount] = True
$aTicketNumber[$iCount] = $TicketToTrack
$aTicketStartTime[$iCount] = @HOUR & ':' & @MIN
EndIf

$checkreturn = 1

EndFunc ;==>CounterMessage
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func RemoveSpace($string)
If StringRight($string, 1) = ' ' Then
;MsgBox('','String before','>' & $find & '<')
$string = StringMid($string, 1, StringLen($string) - 1)
;MsgBox('','String after','>' & $find & '<')
Return $string
Else
Return $string
EndIf

EndFunc ;==>RemoveSpace
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func CheckTime($count, $StatusCheck = False)
Local $TimeElapse = ''
Local $Sec = 0, $Min = 0, $Hour = 0
Local $TempTimeKeeper = ''
$ASecond = TimerDiff($timeKeeper)
;If Mod($ASecond, 1000) > 995 Or Mod($ASecond, 1000) < 5 Then ConsoleWrite('calling checktime ' & Round($ASecond / 1000) & ' count = ' & $count & @CRLF)

For $y = 0 To UBound($aTimerCheck) - 1
If $aTimerCheck[$y] = True Or $StatusCheck = True Then

For $x = 0 To UBound($aTimer) - 1
If $aTimer[$x] <> False Then
$TimeElapse = TimerDiff($aTimer[$x])
If $TimeElapse > 1000 * 60 * 60 Then
MsgBox(262144, 'Escalate Ticket ' & $aTicketNumber[$x], 'One Hour has passed!!! Ticket Number is in clipboard')
$aTicketNumber[$x] = RemoveSpace($aTicketNumber[$x])
ClipPut($aTicketNumber[$x])
$aTimer[$x] = TimerInit()
;AM16329254
Else
If $StatusCheck = True Then
If $aShowAllStatus[$x] <> '' Then
If StringInStr($aShowAllStatus[$x], ':') Then
$Sec = 0
$Min = 0
$Hour = 0

$TempTimeKeeper = Round($TimeElapse / 1000, 0)

If $TempTimeKeeper >= 60 * 60 Then
$Hour = Int($TempTimeKeeper / 60 / 60)
$TempTimeKeeper = $TempTimeKeeper - (60 * 60 * $Hour)
EndIf

If $TempTimeKeeper >= 60 Then
$Min = Int($TempTimeKeeper / 60)
$TempTimeKeeper = $TempTimeKeeper - (60 * $Min)
EndIf

If $TempTimeKeeper >= 1 Then
$Sec = Int($TempTimeKeeper)
EndIf
$aShowAllStatus[$x] = $Hour & ':' & $Min & ':' & $Sec & ' ELAPSED FOR ' & $aTicketNumber[$x] & ' Time Started: ' & $aTicketStartTime[$x]

Else

$Sec = 0
$Min = 0
$Hour = 0

$TempTimeKeeper = Round($TimeElapse / 1000, 0)

If $TempTimeKeeper >= 60 * 60 Then
$Hour = Int($TempTimeKeeper / 60 / 60)
$TempTimeKeeper = $TempTimeKeeper - (60 * 60 * $Hour)
EndIf

If $TempTimeKeeper >= 60 Then
$Min = Int($TempTimeKeeper / 60)
$TempTimeKeeper = $TempTimeKeeper - (60 * $Min)
EndIf

If $TempTimeKeeper >= 1 Then
$Sec = Int($TempTimeKeeper)
EndIf

$aShowAllStatus[$x] = $Hour & ':' & $Min & ':' & $Sec & ' ELAPSED FOR ' & $aTicketNumber[$x]

EndIf

Else
$Sec = 0
$Min = 0
$Hour = 0

$TempTimeKeeper = Round($TimeElapse / 1000, 0)

If $TempTimeKeeper >= 60 * 60 Then
$Hour = Int($TempTimeKeeper / 60 / 60)
$TempTimeKeeper = $TempTimeKeeper - (60 * 60 * $Hour)
EndIf

If $TempTimeKeeper >= 60 Then
$Min = Int($TempTimeKeeper / 60)
$TempTimeKeeper = $TempTimeKeeper - (60 * $Min)
EndIf

If $TempTimeKeeper >= 1 Then
$Sec = Int($TempTimeKeeper)
EndIf
$aShowAllStatus[$x] = $Hour & ':' & $Min & ':' & $Sec & ' ELAPSED FOR ' & $aTicketNumber[$x]

EndIf

EndIf

EndIf

EndIf

Next

EndIf

Next
$TimeElapse = ''
Return
EndFunc ;==>CheckTime
Edited by nitekram

2¢

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

I believe it has much to do with deleting the last element from your arrays. if you set $iTimerCount to 1 in your Global then it works.

edit: I modified your original to Dim the arrays again if they are emptied, and delete the empty 0 element if it exists at the beginning of the GUI function. Dirty, but it seems to work.

#include <array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Date.au3>

Opt("TrayMenuMode", 3)

Global $aTimer[2], $aTimerCheck[2], $aTicketNumber[2], $aTicketStartTime[2], $iTimerCount = 0
Global $aShowAllStatus[UBound($aTimer)]
Global $timeKeeper = TimerInit()
Global $countingwhileloop = 0, $checkreturn = 1

Global $stimersitem = TrayCreateItem("Timer(s)")
Global $aDisplayItem = TrayCreateItem("DisplayArrayTimer(s)")
TrayCreateItem("")
Global $exititem = TrayCreateItem("Exit")

TraySetState()

Local $timer = 0
While 1
$Tray_msg = TrayGetMsg()

Select
Case $Tray_msg = $stimersitem
$checkreturn = CounterMessage($iTimerCount)
If $checkreturn <> -1 Then $iTimerCount += 1

Case $Tray_msg = $aDisplayItem
CheckTime('', True)
GUI_Escalation()

Case $Tray_msg = $exititem
Exit
EndSelect

$countingwhileloop += 1
CheckTime($countingwhileloop, False)
WEnd


Func GUI_Escalation() ; Escalation Manager
Local $CheckBoxAlerts[2]
Local $aDeleteAlert[2]

If $aTicketNumber[0] = "" Then _ArrayDelete($aTicketNumber , 0)
If $aTimerCheck[0] = "" Then _ArrayDelete($aTimerCheck , 0)
If $aTimer[0] = "" Then _ArrayDelete($aTimer , 0)
If $aTicketNumber[0] = "" Then _ArrayDelete($aTicketNumber , 0)
If $aTicketStartTime[0] = "" Then _ArrayDelete($aTicketStartTime , 0)
If $aShowAllStatus[0] = "" Then _ArrayDelete($aShowAllStatus , 0)


$Height = (UBound($aShowAllStatus) * 35) + 100

If UBound($aShowAllStatus) >= UBound($CheckBoxAlerts) Then
For $x = 0 To UBound($aShowAllStatus) - 1
_ArrayAdd($CheckBoxAlerts, '')
Next
EndIf

$GUI_Alerts = GUICreate('Escalation Manager', 350, $Height)

For $x = 0 To UBound($aShowAllStatus) - 1
If $aShowAllStatus[$x] <> '' Then
$CheckBoxAlerts[$x] = GUICtrlCreateCheckbox($aShowAllStatus[$x], 5, $x * 35)
EndIf
Next

$ButtonAlerts = GUICtrlCreateButton('Remove Alert', 200, $Height - 50, 100, 35)
GUISetState(@SW_SHOW) ; will display an empty dialog box

While 1
$msg_Escaltion = GUIGetMsg()
If $msg_Escaltion = $GUI_EVENT_CLOSE Then
GUISetState(@SW_HIDE)
GUIDelete()
ExitLoop
EndIf

If $msg_Escaltion = $ButtonAlerts Then
;MsgBox('','','button pressed')

For $x = 0 To UBound($aShowAllStatus) - 1
If BitAND(GUICtrlRead($CheckBoxAlerts[$x]), $GUI_CHECKED) = $GUI_CHECKED Then
;MsgBox('', 'checked', '$CheckBoxAlerts[$x] = ' & $CheckBoxAlerts[$x])

If $x >= UBound($aDeleteAlert) - 1 Then
ConsoleWrite('Adding Array element ' & $x & @CRLF)
_ArrayAdd($aDeleteAlert, $x)
;_ArrayDisplay($aDeleteAlert, 'added')
Else
ConsoleWrite('Array element ' & $x & @CRLF)
$aDeleteAlert[$x] = $x
;_ArrayDisplay($aDeleteAlert, 'not added')
EndIf
EndIf
Next
;_ArrayDisplay($aDeleteAlert, 'not sorted')
_ArraySort($aDeleteAlert, 1)
;_ArrayDisplay($aDeleteAlert, 'sorted')

For $y = UBound($aShowAllStatus) - 1 To 0 Step -1
;MsgBox('','$y',$y)

For $x = 0 To UBound($aDeleteAlert) - 1
;MsgBox('','$aDeleteAlert[$x]',$aDeleteAlert[$x])
If $y == $aDeleteAlert[$x] Then
;MsgBox('', '$y = ' & $aDeleteAlert[$x], 'match')
GUICtrlSetState($CheckBoxAlerts[$y], $GUI_HIDE)
GUICtrlSetState($CheckBoxAlerts[$y], $GUI_UNCHECKED)
_ArrayDelete($aShowAllStatus, $y)
_ArrayDelete($aTimer, $y)
_ArrayDelete($aTimerCheck, $y)
_ArrayDelete($aTicketNumber, $y)
_ArrayDelete($aTicketStartTime, $y)
$iTimerCount -= 1
ExitLoop
Else
;MsgBox('', 'NONENONENONE', 'match')
EndIf
Next
Next

GUISetState(@SW_HIDE)
GUIDelete()
ExitLoop

EndIf
WEnd

EndFunc ;==>GUI_Escalation
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func CounterMessage($iCount)
Local $TicketToTrack

$TicketToTrack = InputBox('Enter AMXXXXXXXX Ticket Number', 'Enter the ticket number to track!')

If @error Or $TicketToTrack = '' Then Return -1
If $iCount >= UBound($aTimer) Then

If not IsArray($aTicketNumber) Then

Dim $aTimer[1]
Dim $aTimerCheck[1]
Dim $aTicketNumber[1]
Dim $aTicketStartTime[1]
Dim $aShowAllStatus[UBound($aTimer)]

EndIf

_ArrayAdd($aTimer, TimerInit())
_ArrayAdd($aTimerCheck, True)
_ArrayAdd($aTicketNumber, $TicketToTrack)
_ArrayAdd($aTicketStartTime, @HOUR & ':' & @MIN)
_ArrayAdd($aShowAllStatus, '')



Else

$aTimer[$iCount] = TimerInit()
$aTimerCheck[$iCount] = True
$aTicketNumber[$iCount] = $TicketToTrack
$aTicketStartTime[$iCount] = @HOUR & ':' & @MIN
EndIf

$checkreturn = 1

EndFunc ;==>CounterMessage
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func RemoveSpace($string)
If StringRight($string, 1) = ' ' Then
;MsgBox('','String before','>' & $find & '<')
$string = StringMid($string, 1, StringLen($string) - 1)
;MsgBox('','String after','>' & $find & '<')
Return $string
Else
Return $string
EndIf

EndFunc ;==>RemoveSpace
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func CheckTime($count, $StatusCheck = False)
Local $TimeElapse = ''
Local $Sec = 0, $Min = 0, $Hour = 0
Local $TempTimeKeeper = ''
$ASecond = TimerDiff($timeKeeper)
;If Mod($ASecond, 1000) > 995 Or Mod($ASecond, 1000) < 5 Then ConsoleWrite('calling checktime ' & Round($ASecond / 1000) & ' count = ' & $count & @CRLF)

For $y = 0 To UBound($aTimerCheck) - 1
If $aTimerCheck[$y] = True Or $StatusCheck = True Then

For $x = 0 To UBound($aTimer) - 1
If $aTimer[$x] <> False Then
$TimeElapse = TimerDiff($aTimer[$x])
If $TimeElapse > 1000 * 60 * 60 Then
MsgBox(262144, 'Escalate Ticket ' & $aTicketNumber[$x], 'One Hour has passed!!! Ticket Number is in clipboard')
$aTicketNumber[$x] = RemoveSpace($aTicketNumber[$x])
ClipPut($aTicketNumber[$x])
$aTimer[$x] = TimerInit()
;AM16329254
Else
If $StatusCheck = True Then
If $aShowAllStatus[$x] <> '' Then
If StringInStr($aShowAllStatus[$x], ':') Then
$Sec = 0
$Min = 0
$Hour = 0

$TempTimeKeeper = Round($TimeElapse / 1000, 0)

If $TempTimeKeeper >= 60 * 60 Then
$Hour = Int($TempTimeKeeper / 60 / 60)
$TempTimeKeeper = $TempTimeKeeper - (60 * 60 * $Hour)
EndIf

If $TempTimeKeeper >= 60 Then
$Min = Int($TempTimeKeeper / 60)
$TempTimeKeeper = $TempTimeKeeper - (60 * $Min)
EndIf

If $TempTimeKeeper >= 1 Then
$Sec = Int($TempTimeKeeper)
EndIf
$aShowAllStatus[$x] = $Hour & ':' & $Min & ':' & $Sec & ' ELAPSED FOR ' & $aTicketNumber[$x] & ' Time Started: ' & $aTicketStartTime[$x]

Else

$Sec = 0
$Min = 0
$Hour = 0

$TempTimeKeeper = Round($TimeElapse / 1000, 0)

If $TempTimeKeeper >= 60 * 60 Then
$Hour = Int($TempTimeKeeper / 60 / 60)
$TempTimeKeeper = $TempTimeKeeper - (60 * 60 * $Hour)
EndIf

If $TempTimeKeeper >= 60 Then
$Min = Int($TempTimeKeeper / 60)
$TempTimeKeeper = $TempTimeKeeper - (60 * $Min)
EndIf

If $TempTimeKeeper >= 1 Then
$Sec = Int($TempTimeKeeper)
EndIf

$aShowAllStatus[$x] = $Hour & ':' & $Min & ':' & $Sec & ' ELAPSED FOR ' & $aTicketNumber[$x]

EndIf

Else
$Sec = 0
$Min = 0
$Hour = 0

$TempTimeKeeper = Round($TimeElapse / 1000, 0)

If $TempTimeKeeper >= 60 * 60 Then
$Hour = Int($TempTimeKeeper / 60 / 60)
$TempTimeKeeper = $TempTimeKeeper - (60 * 60 * $Hour)
EndIf

If $TempTimeKeeper >= 60 Then
$Min = Int($TempTimeKeeper / 60)
$TempTimeKeeper = $TempTimeKeeper - (60 * $Min)
EndIf

If $TempTimeKeeper >= 1 Then
$Sec = Int($TempTimeKeeper)
EndIf
$aShowAllStatus[$x] = $Hour & ':' & $Min & ':' & $Sec & ' ELAPSED FOR ' & $aTicketNumber[$x]

EndIf

EndIf

EndIf

EndIf

Next

EndIf

Next
$TimeElapse = ''
Return
EndFunc ;==>CheckTime
Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

Sorry was off work and sick...

I tried your second solution, and although it works - if there are no alarms and you try to see if there are any alarms it will crash.

I did use your first solution though - changing the variable to 1 rather then 0 works - it messes with the format, but I think I should be able to fix that.

Thanks again for your help

2¢

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

Working as described:

#include <array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Date.au3>

Opt("TrayMenuMode", 3)

Global $aTimer[2], $aTimerCheck[2], $aTicketNumber[2], $aTicketNumberElaspeTime[2], $aTicketStartTime[2], $iTimerCount = 0
Global $aShowAllStatus[UBound($aTimer)]
Global $timeKeeper = TimerInit()
Global $countingwhileloop = 0, $checkreturn = 1

Global $stimersitem = TrayCreateItem("Timer(s)")
Global $aDisplayItem = TrayCreateItem("DisplayArrayTimer(s)")
TrayCreateItem("")
Global $exititem = TrayCreateItem("Exit")

TraySetState()

Local $timer = 0
While 1
    $Tray_msg = TrayGetMsg()

    Select
        Case $Tray_msg = $stimersitem
            $checkreturn = CounterMessage($iTimerCount)
            If $checkreturn <> -1 Then $iTimerCount += 1

        Case $Tray_msg = $aDisplayItem
            CheckTime('', True)
            GUI_Escalation()

        Case $Tray_msg = $exititem
            Exit
    EndSelect

    $countingwhileloop += 1
    CheckTime($countingwhileloop, False)
WEnd


Func GUI_Escalation() ; Escalation Manager
    Local $CheckBoxAlerts[2]
    Local $aDeleteAlert[2]
    Local $iCountAlerts = 0

#cs
    If $aTicketNumber[0] = "" Then _ArrayDelete($aTicketNumber, 0)
    If $aTimerCheck[0] = "" Then _ArrayDelete($aTimerCheck, 0)
    If $aTimer[0] = "" Then _ArrayDelete($aTimer, 0)
    If $aTicketNumber[0] = "" Then _ArrayDelete($aTicketNumber, 0)
    If $aTicketStartTime[0] = "" Then _ArrayDelete($aTicketStartTime, 0)
    If $aShowAllStatus[0] = "" Then _ArrayDelete($aShowAllStatus, 0)
#ce


    $Height = (UBound($aShowAllStatus) * 35) + 100

    If UBound($aShowAllStatus) >= UBound($CheckBoxAlerts) Then
        For $x = 0 To UBound($aShowAllStatus) - 1
            _ArrayAdd($CheckBoxAlerts, '')
        Next
    EndIf

    $GUI_Alerts = GUICreate('Escalation Manager', 350, $Height)

    For $x = 0 To UBound($aShowAllStatus) - 1
        ConsoleWrite($aShowAllStatus[$x] & @CRLF)
        If $aShowAllStatus[$x] <> '' Then
            $CheckBoxAlerts[$x] = GUICtrlCreateCheckbox($aShowAllStatus[$x], 5, $iCountAlerts * 35)
        Else
            $iCountAlerts -= 1
            ;If UBound($aShowAllStatus) = 2 And $x = 0 Then GUICtrlCreateCheckbox($aShowAllStatus[$x], 5, $x * 35)
            ;MsgBox('','$x = ' & $x & ' UBound($aShowAllStatus) = ' & UBound($aShowAllStatus),'$aShowAllStatus[$x] = ' & $aShowAllStatus[$x])
            ;ExitLoop
        EndIf
        $iCountAlerts += 1
    Next

    $ButtonAlerts = GUICtrlCreateButton('Remove Alert', 200, $Height - 50, 100, 35)
    GUISetState(@SW_SHOW) ; will display an empty dialog box

    While 1
        $msg_Escaltion = GUIGetMsg()
        If $msg_Escaltion = $GUI_EVENT_CLOSE Then
            GUISetState(@SW_HIDE)
            GUIDelete()
            ExitLoop
        EndIf

        If $msg_Escaltion = $ButtonAlerts Then
            ;MsgBox('','','button pressed')

            For $x = 0 To UBound($aShowAllStatus) - 1
                If BitAND(GUICtrlRead($CheckBoxAlerts[$x]), $GUI_CHECKED) = $GUI_CHECKED Then
                    ;MsgBox('', 'checked', '$CheckBoxAlerts[$x] = ' & $CheckBoxAlerts[$x])
                    If $x >= UBound($aDeleteAlert) - 1 Then
                        ConsoleWrite('Adding Array element to be deleted ' & $x & @CRLF)
                        _ArrayAdd($aDeleteAlert, $x)
                        ;_ArrayDisplay($aDeleteAlert, 'added')
                    Else
                        ConsoleWrite('Array element to be deleted ' & $x & @CRLF)
                        $aDeleteAlert[$x] = $x
                        ;_ArrayDisplay($aDeleteAlert, 'not added')
                    EndIf
                EndIf
            Next
            ;_ArrayDisplay($aDeleteAlert, 'not sorted')
            _ArraySort($aDeleteAlert, 1)
            ;_ArrayDisplay($aDeleteAlert, 'sorted')

            For $y = UBound($aShowAllStatus) - 1 To 0 Step -1
                ;MsgBox('','$y',$y)

                For $x = 0 To UBound($aDeleteAlert) - 1
                    ;MsgBox('','$aDeleteAlert[$x]',$aDeleteAlert[$x])
                    If $y == $aDeleteAlert[$x] Then
                        ;MsgBox('', '$y = ' & $aDeleteAlert[$x], 'match')
                        GUICtrlSetState($CheckBoxAlerts[$y], $GUI_HIDE)
                        GUICtrlSetState($CheckBoxAlerts[$y], $GUI_UNCHECKED)
                        _ArrayDelete($aShowAllStatus, $y)
                        _ArrayDelete($aTimer, $y)
                        _ArrayDelete($aTimerCheck, $y)
                        _ArrayDelete($aTicketNumber, $y)
                        _ArrayDelete($aTicketNumberElaspeTime, $y)
                        _ArrayDelete($aTicketNumberElaspeTime, $y)
                        _ArrayDelete($aTicketStartTime, $y)
                        $iTimerCount -= 1
                        ExitLoop
                    Else
                        ;MsgBox('', 'NONENONENONE', 'match')
                    EndIf
                Next
            Next

            GUISetState(@SW_HIDE)
            GUIDelete()
            ExitLoop

        EndIf
    WEnd

EndFunc   ;==>GUI_Escalation
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func CounterMessage($iCount)
    Local $TicketToTrack, $ElapseTime

    $TicketToTrack = InputBox('Enter AMXXXXXXXX Ticket Number', 'Enter the ticket number to track!')
    $ElapseTime = InputBox('Enter the time in minutes', 'Enter the total time for escalation!', 60)
    If @error Or $TicketToTrack = '' Then Return -1
    If $iCount >= UBound($aTimer) Then

        If Not IsArray($aTicketNumber) Then

            Dim $aTimer[1]
            Dim $aTimerCheck[1]
            Dim $aTicketNumber[1]
            Dim $aTicketNumberElaspeTime[1]
            Dim $aTicketStartTime[1]
            Dim $aShowAllStatus[UBound($aTimer)]

        EndIf

        _ArrayAdd($aTimer, TimerInit())
        _ArrayAdd($aTimerCheck, True)
        _ArrayAdd($aTicketNumber, $TicketToTrack)
        _ArrayAdd($aTicketNumberElaspeTime, $ElapseTime)
        _ArrayAdd($aTicketStartTime, @HOUR & ':' & @MIN)
        _ArrayAdd($aShowAllStatus, '')



    Else

        $aTimer[$iCount] = TimerInit()
        $aTimerCheck[$iCount] = True
        $aTicketNumber[$iCount] = $TicketToTrack
        $aTicketNumberElaspeTime[$iCount] = $ElapseTime
        $aTicketStartTime[$iCount] = @HOUR & ':' & @MIN
    EndIf

    $checkreturn = 1

EndFunc   ;==>CounterMessage
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func RemoveSpace($string)
    If StringRight($string, 1) = ' ' Then
        ;MsgBox('','String before','>' & $find & '<')
        $string = StringMid($string, 1, StringLen($string) - 1)
        ;MsgBox('','String after','>' & $find & '<')
        Return $string
    Else
        Return $string
    EndIf

EndFunc   ;==>RemoveSpace
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func CheckTime($count, $StatusCheck = False)
    Local $TimeElapse = ''
    Local $Sec = 0, $Min = 0, $Hour = 0
    Local $TempTimeKeeper = ''
    $ASecond = TimerDiff($timeKeeper)
    ;If Mod($ASecond, 1000) > 995 Or Mod($ASecond, 1000) < 5 Then ConsoleWrite('calling checktime ' & Round($ASecond / 1000) & ' count = ' & $count & @CRLF)

    For $y = 0 To UBound($aTimerCheck) - 1
        If $aTimerCheck[$y] = True Or $StatusCheck = True Then

            For $x = 0 To UBound($aTimer) - 1
                If $aTimer[$x] <> False Then
                    $TimeElapse = TimerDiff($aTimer[$x])
                    If $TimeElapse > 1000 * 60 * $aTicketNumberElaspeTime[$x] Then
                        MsgBox(262144, 'Escalate Ticket ' & $aTicketNumber[$x], $aTicketNumberElaspeTime[$x] & ' minute(s) have passed!!! Ticket Number is in clipboard')
                        $aTicketNumber[$x] = RemoveSpace($aTicketNumber[$x])
                        ClipPut($aTicketNumber[$x])
                        $aTimer[$x] = TimerInit()
                        ;AM16329254
                    Else
                        If $StatusCheck = True Then
                            If $aShowAllStatus[$x] <> '' Then
                                If StringInStr($aShowAllStatus[$x], ':') Then
                                    $Sec = 0
                                    $Min = 0
                                    $Hour = 0

                                    $TempTimeKeeper = Round($TimeElapse / 1000, 0)

                                    If $TempTimeKeeper >= 60 * 60 Then
                                        $Hour = Int($TempTimeKeeper / 60 / 60)
                                        $TempTimeKeeper = $TempTimeKeeper - (60 * 60 * $Hour)
                                    EndIf

                                    If $TempTimeKeeper >= 60 Then
                                        $Min = Int($TempTimeKeeper / 60)
                                        $TempTimeKeeper = $TempTimeKeeper - (60 * $Min)
                                    EndIf

                                    If $TempTimeKeeper >= 1 Then
                                        $Sec = Int($TempTimeKeeper)
                                    EndIf
                                    $aShowAllStatus[$x] = $Hour & ':' & $Min & ':' & $Sec & ' ELAPSED FOR ' & $aTicketNumber[$x] & ' Time Started: ' & $aTicketStartTime[$x] & ' -->> Timer = ' & $aTicketNumberElaspeTime[$x] & ' minutes'

                                Else

                                    $Sec = 0
                                    $Min = 0
                                    $Hour = 0

                                    $TempTimeKeeper = Round($TimeElapse / 1000, 0)

                                    If $TempTimeKeeper >= 60 * 60 Then
                                        $Hour = Int($TempTimeKeeper / 60 / 60)
                                        $TempTimeKeeper = $TempTimeKeeper - (60 * 60 * $Hour)
                                    EndIf

                                    If $TempTimeKeeper >= 60 Then
                                        $Min = Int($TempTimeKeeper / 60)
                                        $TempTimeKeeper = $TempTimeKeeper - (60 * $Min)
                                    EndIf

                                    If $TempTimeKeeper >= 1 Then
                                        $Sec = Int($TempTimeKeeper)
                                    EndIf

                                    $aShowAllStatus[$x] = $Hour & ':' & $Min & ':' & $Sec & ' ELAPSED FOR ' & $aTicketNumber[$x] & ' Time Started: ' & $aTicketStartTime[$x] & ' -->> Timer = ' & $aTicketNumberElaspeTime[$x] & ' minutes'

                                EndIf

                            Else
                                $Sec = 0
                                $Min = 0
                                $Hour = 0

                                $TempTimeKeeper = Round($TimeElapse / 1000, 0)

                                If $TempTimeKeeper >= 60 * 60 Then
                                    $Hour = Int($TempTimeKeeper / 60 / 60)
                                    $TempTimeKeeper = $TempTimeKeeper - (60 * 60 * $Hour)
                                EndIf

                                If $TempTimeKeeper >= 60 Then
                                    $Min = Int($TempTimeKeeper / 60)
                                    $TempTimeKeeper = $TempTimeKeeper - (60 * $Min)
                                EndIf

                                If $TempTimeKeeper >= 1 Then
                                    $Sec = Int($TempTimeKeeper)
                                EndIf
                                $aShowAllStatus[$x] = $Hour & ':' & $Min & ':' & $Sec & ' ELAPSED FOR ' & $aTicketNumber[$x] & ' Time Started: ' & $aTicketStartTime[$x] & ' -->> Timer = ' & $aTicketNumberElaspeTime[$x] & ' minutes'

                            EndIf

                        EndIf

                    EndIf

                EndIf

            Next

        EndIf

    Next
    $TimeElapse = ''
    Return
EndFunc   ;==>CheckTime

EDIT - made it so you can set the time for the alert (timer)

Edited by nitekram

2¢

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

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