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.
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.
[ autoit ]
#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