Sign in to follow this  
Followers 0
GrimSage

how do I Stop Script without exiting

2 posts in this topic

I am wondering if there is a way to stop the execution of a script without exiting the GUI. I have searched the forum but have not found a way.

The reason is that sometimes in the middle I will have to stop and go to something else but I dont want to have to open the GUI again.

Is there a way to Stop the script without closing the GUI?

Thank you for any assistance.

My Script:

CODE
Global $Oncall = ""

Global $title = ""

Global $IMnum = ""

Global $title = ""

Global $IMnum = ""

Global $AlertTxt = ""

Global $UpdTime = ""

Global $Paused

Global $TicketCount = 0

Global $SCHandle = WinGetHandle("Anthem Enterprise","")

;Check to see if required applications are open.

if @error Then

MsgBox(0,"Error","Service Center Not found" & @CRLF & "Bring up Service Center and then rerun program.")

Exit 1

EndIf

Global $NPhandle = WinGetHandle("Untitled - Notepad", "")

Global $NPCntrl = "Edit1"

if @error Then

$NPhandle = WinGetHandle("Notepad++", "")

if @error Then

Run("notepad.exe")

WinWait("Untitled - Notepad","")

$NPhandle = WinGetHandle("Untitled - Notepad", "")

Else

$NPCntrl = "Scintilla1"

EndIf

EndIf

ControlSend($NPhandle,"",$NPCntrl,"-------Tivoli Traps-------" & @CRLF)

HotKeySet("{PAUSE}", "TogglePause")

HotKeySet("{ESC}", "Terminate")

HotKeySet("+!d", "ShowMessage")

HotKeySet("{F5}", "AssignTck")

HotKeySet("{F6}", "LastRun")

Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",4)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

;New Form to Use

#include <GUIConstants.au3>

$frmMain = GUICreate("Service Center Ticket Assignment", 272, 78, 193, 115)

$lblTotal = GUICtrlCreateLabel("Total: 000", 144, 40, 61, 17)

$txtNumToAssign = GUICtrlCreateInput("6", 120, 8, 33, 21)

$cmdTicket = GUICtrlCreateButton("Assign Ticket(s)", 168, 8, 83, 21, 0)

$lblNumToAssign = GUICtrlCreateLabel("Number of Tickets to Assign", 16, 8, 81, 33)

GUISetState(@SW_SHOW)

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $frmMain

Case $txtNumToAssign

Case $cmdTicket

$k = GUICtrlRead($txtNumToAssign)

if $k == 1 Then

AssignTck()

Else

$i=1

while $i <= GUICtrlRead($txtNumToAssign)

;Msgbox(0,"I=",$i)

AssignTck()

$i += 1

WinWait("ServiceCenter","")

WinWaitActive("ServiceCenter","")

Send("!y");

Sleep(7000)

WEnd

EndIf

EndSwitch

WEnd

#cs

$frmMain = GUICreate("Assign Ticket", 206, 32, 191, 116, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS))

$cmdTicket = GUICtrlCreateButton("Assign Ticket", 0, 0, 73, 25, 0)

GUICtrlSetTip(-1, "F5")

$lblTotal = GUICtrlCreateLabel("Total: 0", 80, 8, 52, 17)

GUISetState(@SW_SHOW)

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit 0

Case $cmdTicket

AssignTck()

EndSwitch

WEnd

#ce

Func TogglePause()

$Paused = NOT $Paused

While $Paused

sleep(100)

ToolTip('Script is "Paused"',0,0)

WEnd

ToolTip("")

EndFunc

Func Terminate()

Exit 0

EndFunc

Func ShowMessage()

MsgBox(4096,"","This is a message.")

EndFunc

Func LastRun()

$LastRunMsg = "Ticket number: " & $IMnum & @CRLF & "Time alert received: " & $UpdTime & @CRLF & "Alert text: " & $AlertTxt & @CRLF & "Platform: INTEL" & @CRLF & "Time support notified: " & @HOUR & @MIN & @CRLF & "On-call person: " & $Oncall & @CRLF & "Updates:"

If StringInStr($AlertTxt,"Tivoli") > 0 Then

Else

$LastRunMsg = $LastRunMsg & "Cold Transfered"

EndIf

MsgBox(0,"Information from Last Run",$LastRunMsg)

EndFunc

Func AssignTck()

$TicketCount+=1

GUICtrlSetData($lblTotal,"Total: " & $TicketCount)

WinWait("Anthem Enterprise","")

If Not WinActive("Anthem Enterprise","") Then WinActivate("Anthem Enterprise","")

WinWaitActive("Anthem Enterprise","")

;Get Ticket number from Service Center Title

$title = WinGetTitle("Anthem Enterprise", "")

$IMnum = StringMid($title,47,6)

#region Get Incident Description

;MouseMove(363,300)

MouseClick("left",123,773,2)

Sleep(500)

Send("^a^c")

Sleep(1000)

$AlertTxt = ClipGet()

#endregion

#cs

Need to do a test to determine what type of ticket it is here, Unix or Intel so that assignment can be done accordingly

Using If StringInStr($AlertTxt,"???") > 0

Mouse Coords for SCIM Text Boxes

System (190,374) (298,374)

Component (190, 394) (298,396)

Item (190,413) (298,414)

module (190,430) (298,423)

#ce

#region Set assign by Skillset

MouseClick("left",367,564,2)

Sleep(500)

#endregion

#region Reset Skillset Group

MouseMove(562,375)

MouseDown("left")

MouseUp("left")

Sleep(500)

Send("^aENTERPRISE INTEL SERVER SUPPORT")

#endregion

#region Get Userid List

MouseClick("left",618,394,1)

;MouseDown("left")

;MouseUp("left")

Sleep(5000)

#endregion

#region Assign UserID

Send("{ENTER}")

Sleep(5000)

#endregion

#region Get Support Name

MouseClick("left",547,415,2)

Sleep(750)

Send("^a^c")

Sleep(1000)

$Oncall = ClipGet()

#endregion

#region Get Update Time and Return

MouseClick("left",146,331,2)

Sleep(500)

MouseClick("left",99,417,2)

Sleep(3500)

MouseClickDrag("left",238,308,199,307)

Send("^c")

Sleep(1000)

$UpdTime = ClipGet()

Send("{F3}")

#endregion

#region Assign action

Sleep(4500)

MouseClick("left",184,353,2)

Sleep(550)

MouseClick("left",332,378,2)

Sleep(550)

Send("Transfer{TAB 3}Assigned to Oncall")

#endregion

;WinWait($NPhandle,"")

;If Not WinActive($NPhandle,"") Then WinActivate($NPhandle,"")

;WinWaitActive($NPhandle,"")

;Send("Ticket number: " & $IMnum & "{ENTER}Time alert received: " & $UpdTime & "{ENTER}Alert text: " & $AlertTxt & "{ENTER}Platform: INTEL{ENTER}Time support notified: " & @HOUR & @MIN & "{ENTER}On-call person: " & $Oncall & "{ENTER}Updates:")

#cs region Update Turnover.

ControlSend($NPhandle,"",$NPCntrl,"Ticket number: " & $IMnum & "{ENTER}Time alert received: " & $UpdTime & "{ENTER}Alert text: " & $AlertTxt & "{ENTER}Platform: INTEL{ENTER}Time support notified: " & @HOUR & @MIN & "{ENTER}On-call person: " & $Oncall & "{ENTER}Updates:")

If StringInStr($AlertTxt,"Tivoli") > 0 Then

ControlSend($NPhandle,"",$NPCntrl,"{ENTER 2}")

Else

ControlSend($NPhandle,"",$NPCntrl,"Cold Transfered{ENTER 2}")

EndIf

#ce endregion

Send("{F10}")

TOOutput()

;WinWait("Anthem Enterprise","")

;If Not WinActive("Anthem Enterprise","") Then WinActivate("Anthem Enterprise","")

;WinWaitActive("Anthem Enterprise","")

;AssignTck()

EndFunc

Func TOOutput()

ControlSend($NPhandle,"",$NPCntrl,"Ticket number: " & $IMnum & "{ENTER}Time alert received: " & $UpdTime & "{ENTER}Alert text: " & $AlertTxt & "{ENTER}Platform: INTEL{ENTER}Time support notified: " & @HOUR & @MIN & "{ENTER}On-call person: " & $Oncall & "{ENTER}Updates:")

If StringInStr($AlertTxt,"Tivoli") > 0 Then

ControlSend($NPhandle,"",$NPCntrl,"{ENTER 2}")

Else

ControlSend($NPhandle,"",$NPCntrl,"Cold Transfered{ENTER 2}")

EndIf

EndFunc

Share this post


Link to post
Share on other sites



not tested**********

Global $Halt = 0
Global $Oncall = ""
Global $title = ""
Global $IMnum = ""
Global $title = ""
Global $IMnum = ""
Global $AlertTxt = ""
Global $UpdTime = ""
Global $Paused
Global $TicketCount = 0
Global $SCHandle = WinGetHandle("Anthem Enterprise", "")

;Check to see if required applications are open.
If @error Then
    MsgBox(0, "Error", "Service Center Not found" & @CRLF & "Bring up Service Center and then rerun program.")
    Exit 1
EndIf
Global $NPhandle = WinGetHandle("Untitled - Notepad", "")
Global $NPCntrl = "Edit1"
If @error Then
    $NPhandle = WinGetHandle("Notepad++", "")
    If @error Then
        Run("notepad.exe")
        WinWait("Untitled - Notepad", "")
        $NPhandle = WinGetHandle("Untitled - Notepad", "")
    Else
        $NPCntrl = "Scintilla1"
    EndIf
EndIf
ControlSend($NPhandle, "", $NPCntrl, "-------Tivoli Traps-------" & @CRLF)
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage")
HotKeySet("{F5}", "AssignTck")
HotKeySet("{F6}", "LastRun")
Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)

;New Form to Use
#include <GUIConstants.au3>

$frmMain = GUICreate("Service Center Ticket Assignment", 272, 78, 193, 115)
$lblTotal = GUICtrlCreateLabel("Total: 000", 144, 40, 61, 17)
$txtNumToAssign = GUICtrlCreateInput("6", 120, 8, 33, 21)
$cmdTicket = GUICtrlCreateButton("Assign Ticket(s)", 168, 8, 83, 21, 0)
$lblNumToAssign = GUICtrlCreateLabel("Number of Tickets to Assign", 16, 8, 81, 33)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    $Halt = 0
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $frmMain

        Case $txtNumToAssign

        Case $cmdTicket
            $k = GUICtrlRead($txtNumToAssign)
            If $k == 1 Then
                AssignTck()
            Else
                $i = 1
                While $i <= GUICtrlRead($txtNumToAssign)
                    ;Msgbox(0,"I=",$i)
                    AssignTck()
                    $i += 1
                    WinWait("ServiceCenter", "")
                    WinWaitActive("ServiceCenter", "")
                    Send("!y");
                    Sleep(7000)
                WEnd
            EndIf
    EndSwitch
WEnd


#cs
    $frmMain = GUICreate("Assign Ticket", 206, 32, 191, 116, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS))
    $cmdTicket = GUICtrlCreateButton("Assign Ticket", 0, 0, 73, 25, 0)
    GUICtrlSetTip(-1, "F5")
    $lblTotal = GUICtrlCreateLabel("Total: 0", 80, 8, 52, 17)
    GUISetState(@SW_SHOW)
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit 0
    Case $cmdTicket
    AssignTck()
    EndSwitch
    WEnd
#ce
Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause
Func Terminate()
    $Halt = 1
EndFunc   ;==>Terminate
Func ShowMessage()
    MsgBox(4096, "", "This is a message.")
EndFunc   ;==>ShowMessage
Func LastRun()
    If $Halt Then Return
    $LastRunMsg = "Ticket number: " & $IMnum & @CRLF & "Time alert received: " & $UpdTime & @CRLF & "Alert text: " & $AlertTxt & @CRLF & "Platform: INTEL" & @CRLF & "Time support notified: " & @HOUR & @MIN & @CRLF & "On-call person: " & $Oncall & @CRLF & "Updates:"
    If StringInStr($AlertTxt, "Tivoli") > 0 Then
        ;
    Else
        $LastRunMsg = $LastRunMsg & "Cold Transfered"
    EndIf
    MsgBox(0, "Information from Last Run", $LastRunMsg)
EndFunc   ;==>LastRun
Func AssignTck()
    If $Halt Then Return
    $TicketCount += 1
    GUICtrlSetData($lblTotal, "Total: " & $TicketCount)
    
    If $Halt Then Return
    WinWait("Anthem Enterprise", "")
    If Not WinActive("Anthem Enterprise", "") Then WinActivate("Anthem Enterprise", "")
    WinWaitActive("Anthem Enterprise", "")
    
    If $Halt Then Return
    ;Get Ticket number from Service Center Title
    $title = WinGetTitle("Anthem Enterprise", "")
    $IMnum = StringMid($title, 47, 6)
    
    If $Halt Then Return
    #region Get Incident Description
    ;MouseMove(363,300)
    MouseClick("left", 123, 773, 2)
    Sleep(500)
    Send("^a^c")
    Sleep(1000)
    $AlertTxt = ClipGet()
    #endregion

    #cs
        Need to do a test to determine what type of ticket it is here, Unix or Intel so that assignment can be done accordingly
        Using If StringInStr($AlertTxt,"???") > 0
        
        
        Mouse Coords for SCIM Text Boxes
        System (190,374) (298,374)
        Component (190, 394) (298,396)
        Item (190,413) (298,414)
        module (190,430) (298,423)
    #ce
    
    If $Halt Then Return
    #region Set assign by Skillset
    MouseClick("left", 367, 564, 2)
    Sleep(500)
    #endregion
    
    If $Halt Then Return
    #region Reset Skillset Group
    MouseMove(562, 375)
    MouseDown("left")
    MouseUp("left")
    
    If $Halt Then Return
    Sleep(500)
    Send("^aENTERPRISE INTEL SERVER SUPPORT")
    #endregion
    
    If $Halt Then Return
    #region Get Userid List
    MouseClick("left", 618, 394, 1)
    ;MouseDown("left")
    ;MouseUp("left")
    Sleep(5000)
    #endregion
    
    If $Halt Then Return
    #region Assign UserID
    Send("{ENTER}")
    Sleep(5000)
    #endregion
    #region Get Support Name
    MouseClick("left", 547, 415, 2)
    Sleep(750)
    Send("^a^c")
    Sleep(1000)
    $Oncall = ClipGet()
    #endregion
    
    If $Halt Then Return
    #region Get Update Time and Return
    MouseClick("left", 146, 331, 2)
    Sleep(500)
    MouseClick("left", 99, 417, 2)
    Sleep(3500)
    MouseClickDrag("left", 238, 308, 199, 307)
    Send("^c")
    Sleep(1000)
    $UpdTime = ClipGet()
    Send("{F3}")
    #endregion
    
    If $Halt Then Return
    #region Assign action
    Sleep(4500)
    MouseClick("left", 184, 353, 2)
    Sleep(550)
    MouseClick("left", 332, 378, 2)
    Sleep(550)
    Send("Transfer{TAB 3}Assigned to Oncall")
    #endregion

    ;WinWait($NPhandle,"")
    ;If Not WinActive($NPhandle,"") Then WinActivate($NPhandle,"")
    ;WinWaitActive($NPhandle,"")
    ;Send("Ticket number: " & $IMnum & "{ENTER}Time alert received: " & $UpdTime & "{ENTER}Alert text: " & $AlertTxt & "{ENTER}Platform: INTEL{ENTER}Time support notified: " & @HOUR & @MIN & "{ENTER}On-call person: " & $Oncall & "{ENTER}Updates:")

    #cs region Update Turnover.
        ControlSend($NPhandle,"",$NPCntrl,"Ticket number: " & $IMnum & "{ENTER}Time alert received: " & $UpdTime & "{ENTER}Alert text: " & $AlertTxt & "{ENTER}Platform: INTEL{ENTER}Time support notified: " & @HOUR & @MIN & "{ENTER}On-call person: " & $Oncall & "{ENTER}Updates:")
        If StringInStr($AlertTxt,"Tivoli") > 0 Then
        ControlSend($NPhandle,"",$NPCntrl,"{ENTER 2}")
        Else
        ControlSend($NPhandle,"",$NPCntrl,"Cold Transfered{ENTER 2}")
        EndIf
    #ce endregion
    
    If $Halt Then Return
    Send("{F10}")
    TOOutput()
    ;WinWait("Anthem Enterprise","")
    ;If Not WinActive("Anthem Enterprise","") Then WinActivate("Anthem Enterprise","")
    ;WinWaitActive("Anthem Enterprise","")
    ;AssignTck()

EndFunc   ;==>AssignTck

Func TOOutput()
    
    If $Halt Then Return
    ControlSend($NPhandle, "", $NPCntrl, "Ticket number: " & $IMnum & "{ENTER}Time alert received: " & $UpdTime & "{ENTER}Alert text: " & $AlertTxt & "{ENTER}Platform: INTEL{ENTER}Time support notified: " & @HOUR & @MIN & "{ENTER}On-call person: " & $Oncall & "{ENTER}Updates:")
    If StringInStr($AlertTxt, "Tivoli") > 0 Then
        ControlSend($NPhandle, "", $NPCntrl, "{ENTER 2}")
    Else
        ControlSend($NPhandle, "", $NPCntrl, "Cold Transfered{ENTER 2}")
    EndIf

EndFunc   ;==>TOOutput

8)


NEWHeader1.png

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  
Followers 0