Jump to content

Recommended Posts

Posted (edited)

Hi All,

I have been using simple but long (200+ line, excluding functions) scripts. So far they all start with a InputBox for the main input($input as below). I recently tried koda and built the go below.

Now i have done some reading of the helpfiles but am abit lost, i need the gui on click of the ok to run the script. I can get it to run on ok but not call the $input, $s_call1 and $s_call2 so the script works.

Any ideas that can point me the right way would be great, thanks!

$Form1 = GUICreate("gui", 321, 171, 222, 148)
$input = GUICtrlCreateInput("", 24, 40, 121, 21)
$s_call1 = GUICtrlCreateInput("", 24, 88, 161, 21)
$s_call2 = GUICtrlCreateInput("", 24, 136, 161, 21)
$ok = GUICtrlCreateButton("OK", 200, 136, 107, 25, 0)
$Label1 = GUICtrlCreateLabel("Label1", 24, 112, 152, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Label2 24, 64, 138, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("Label3", 24, 16, 43, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Pic1 = GUICtrlCreatePic("e:\pic\script.bmp", 192, 8, 121, 73, BitOR($SS_NOTIFY,$WS_GROUP))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    $nMsg = GUIGetMsg()
    Select 
        Case $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $ok 
            If GuiCtrlRead($ifms) = "" Then
                MsgBox(1, "Error", "Please Enter An Input")
                ContinueLoop
            EndIf
            If GuiCtrlRead($$s_call1) = "" Then
                MsgBox(1, "Error", "Please Enter A S_call1")
                ContinueLoop
            EndIf
            If GuiCtrlRead($s_call1) = "" Then
                MsgBox(1, "Error", "Please Enter A S_call2")
                ContinueLoop
            EndIf           
            ;Big script goes here.
            
        EndSelect
    WEnd
Edited by autonoob
Posted (edited)

orginal, ie no gui (also pull 2 inputs from a ie window, not an input

; ----------------------------------------------------------------------------
; header 
; ----------------------------------------------------------------------------


; ----------------------------------------------------------------------------
; INCLUDE FILES
; ----------------------------------------------------------------------------
#include <file.au3>
#include <IE.au3>
#include <GuiConstants.au3>
#include <GuiCombo.au3>
#include <ifms.au3>


; ----------------------------------------------------------------------------
; VARIABLES
; ----------------------------------------------------------------------------



; General Initialisations
$closure = "Phone"                              ; How otsrv1 notify us of case closure, either Phone or Email
Global $error_count = 0                     
$continue = 0
$pos1 = 0
$max_errors = 10                                ; specifies the max number of errors in a row that can occur

$time_nff = 300 ; the length of time in seconds to wait prior to checking hold queue again if no faults currently exist
$time_rst = 30  ; the length of time to wait, to log another fault after succesfully logging one


; ----------------------------------------------------------------------------
; MAIN BODY
; ----------------------------------------------------------------------------
$ifms = InputBox("Auto IFMS", "Enter IFMS Number", "", "")
While (($continue <> 1) & ($error_count < $max_errors))

    $temp = WebIFMS($ifms)
    
    $manual_ovr = Not StringInStr($temp,"lwt") ;
    
    $ph = PR_Getsumm($temp)
    If $ph == 0 Then
        $error = "No CCID Or Incorrect Format."
        PR_errorbox($error)
        Exit
    EndIf

    
    $cust = PR_GetContact($temp)

    
    $type = PR_GetPrType($temp)
;   
    $fault_type = PR_Type($type,$temp)
    If $fault_type[0] == 0 Then 
        Write_Error($ifms,"Error with PR Type")
        ContinueLoop
    EndIf

    $oIE = _IECreate("https://serviceweb.otsrv1.com.au/Login.jsp",0,1)
    $pagecheck = _IEBodyReadText($oIE)
    If StringInStr($pagecheck,"Network Access Message") Then
        $error = "LOLS is Timing Out"
        _IEQuit($oIE)   
        PR_errorbox($error)
        Exit
    EndIf
    _IENavigate($oIE,"https://serviceweb.otsrv1.com.au/wss/home/serviceNumberInput")

        If StringInStr($pagecheck,"Network Access Message") Then
        $error = "LOLS is Timing Out"
        _IEQuit($oIE)   
        PR_errorbox($error)
        Exit
    Endif
    If CheckURL($oIE,"https://serviceweb.otsrv1.com.au/wss/home/serviceNumberInput",$ifms) Then ContinueLoop
    $o_form = _IEFormGetCollection ($oIE, 0)
    $oQuery = _IEFormElementGetCollection ($o_form, 0)
    _IEFormElementSetValue ($oQuery, $ph)
    _IEFormSubmit ($o_form)
    If CheckURL($oIE,"https://serviceweb.otsrv1.com.au/wss/serviceNumberInput/caseSearch",$ifms) Then ContinueLoop
    $pagecheck = _IEBodyReadText($oIE)

    If StringInStr($pagecheck,"ownership") Or StringInStr($pagecheck,"otsrv1 maintained") Or StringInStr($pagecheck,"otsrv1 does not recognise") Or StringInStr($pagecheck,"Our records indicate")Then
        $error = "Service not owned"
        _IEQuit($oIE)   
        PR_errorbox($error)
        Exit
    EndIf

    If StringInStr($pagecheck,"OPTUS NETWORKS PTY LIMITED") Then
        $error = "ULL OPTUS NETWORKS PTY LIMITED"
        _IEQuit($oIE)   
        PR_errorbox($error)
        Exit
    EndIf

    If StringInStr($pagecheck,"active Cases listed against Service Number") Then 
        $error = "This Service has an Active case already logged"
        _IEQuit($oIE)   
        PR_errorbox($error)
        Exit
    EndIf


    $o_form = _IEFormGetObjByName ($oIE, "f1")
    $o_ifms= _IEFormElementGetObjByName ($o_form, "CUSTOMER_REF_ID")
    $o_temp = _IEFormElementGetObjByName ($o_form, "NOTE")


    _IEFormElementSetValue ($o_ifms, $ifms)


    _IEFormElementSetValue ($o_temp, "Our isolation tests indicate that there are issues on the ULL. The end user is reporting that this service is completely down. Please investigate")

    
    _IEFormElementCheckBoxSelect($o_form,"on", "", 1, "byValue")
    _IEFormElementRadioSelect($o_form,"Workable","FAULT_IMPACT",1,"byValue")

    $o_cat = _IEFormElementGetObjByName ($o_form, "FAULT_CATEGORY")
    $o_sym = _IEFormElementGetObjByName ($o_form, "FAULT_SYMPTOM")

    _IEFormElementOptionselect($o_cat,"Problem with ADSL service",1,"byText")

    _IEFormElementOptionselect($o_sym,$fault_type[0],1,"byText")


    _IEFormImageClick ($oIE, "next.gif")

    If CheckURL($oIE,"https://serviceweb.otsrv1.com.au/wss/serviceDetails/next",$ifms) Then ContinueLoop
    $pagecheck = _IEBodyReadHTML($oIE)
    If StringInStr($pagecheck,"Network Access Message") Then
        $error = "LOLS is Timing Out"
        _IEQuit($oIE)   
        PR_errorbox($error)
        Exit
    Endif

    If StringInStr($pagecheck,"OutageInformation") Then
        $error = "Outage effecting service"
        _IEQuit($oIE)   
        PR_errorbox($error)
        Exit
    EndIf
    $o_form = _IEFormGetObjByName ($oIE, "formName")
    Call($fault_type[1],$o_form)


    _IEFormImageClick ($oIE, "next.gif")
    _IENavigate($oIE,"https://serviceweb.otsrv1.com.au/wss/CaseMgmtCentral/centralnext")

    If StringInStr($pagecheck,"Network Access Message") Then
        $error = "LOLS is Timing Out"
        _IEQuit($oIE)   
        PR_errorbox($error)
        Exit
    Endif
    $o_form = _IEFormGetObjByName ($oIE, "additionalDetails")
    $o_det = _IEFormElementGetObjByName ($o_form, "AdditionalDetails")
    _IEFormElementSetValue ($o_det, "N2000957K")

    _IEFormSubmit($o_form)   

    If CheckURL($oIE,"https://serviceweb.otsrv1.com.au/wss/additionalDetails/next",$ifms) Then ContinueLoop

    $o_form = _IEFormGetObjByName ($oIE, "myform")
    $o_cust= _IEFormElementGetObjByName ($o_form, "SiteFirstName")
    $o_custl = _IEFormElementGetObjByName ($o_form, "SiteLastName")
    $o_ph = _IEFormElementGetObjByName ($o_form, "SitePhone")
    $o_rep= _IEFormElementGetObjByName ($o_form, "ReportFirstName")
    $o_repl = _IEFormElementGetObjByName ($o_form, "ReportLastName")

    
    $repid = randomname()
    _IEFormElementSetValue ($o_rep, $repid[0])
    _IEFormElementSetValue ($o_repl, $repid[1])
    _IEFormElementSetValue ($o_custl, "n/a")


    _IEFormElementSetValue ($o_cust, $cust[1])
    _IEFormElementSetValue ($o_ph, $ph)
    
    $o_clos = _IEFormElementGetObjByName($o_form,"ClosureNotification")
    _IEFormElementOptionselect($o_clos,$closure,1,"byText")
    $o_start = _IEFormElementGetObjByName($o_form,"SiteStartHours")
    _IEFormElementOptionselect($o_start,"08:00",1,"byValue")
    $o_end = _IEFormElementGetObjByName($o_form,"SiteEndHours")
    _IEFormElementOptionselect($o_end,"17:00",1,"byValue")


    _IEFormImageClick ($oIE, "next.gif")

    If CheckURL($oIE,"https://serviceweb.otsrv1.com.au/wss/contact/next",$ifms) Then ContinueLoop

    If StringInStr($pagecheck,"Network Access Message") Then
        $error = "LOLS is Timing Out"
        _IEQuit($oIE)   
        PR_errorbox($error)
        Exit
    Endif

    $oForm = _IEFormGetCollection ($oIE,0)
    _IEFormSubmit ($oForm)


    $submit = _IEBodyReadText ($oIE)


    _IEQuit($oIE)


    $pos1 = StringInStr($submit,"otsrv1 Case Reference Number:") + 31
    $tcase = StringMid($submit,$pos1,9)


    $pos1 = StringInStr($submit,"Target Restoration Date / Time:") + 32
    $tres = StringMid($submit,$pos1,19)


    $t_restoredate = PR_treference ($tres)
    LOLS($ifms,$tcase,$tres)
    $error_count = 0
    ExitLoop
WEnd
Edited by autonoob
Posted (edited)

Attempt At gui

edit: added corect s_ph and s_cust

$Form1 = GUICreate("Wilson 1.0", 321, 171, 222, 148)
$ifms = GUICtrlCreateInput("", 24, 40, 121, 21)
$s_cust = GUICtrlCreateInput("", 24, 88, 161, 21)
$s_ph = GUICtrlCreateInput("", 24, 136, 161, 21)
$ok = GUICtrlCreateButton("OK", 200, 136, 107, 25, 0)
$Label1 = GUICtrlCreateLabel("Site Contact Number", 24, 112, 152, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Site Contact Name", 24, 64, 138, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("IFMS", 24, 16, 43, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Pic1 = GUICtrlCreatePic("e:\wilson\optus.bmp", 192, 8, 121, 73, BitOR($SS_NOTIFY,$WS_GROUP))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Select 
        Case $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $ok 
            If GuiCtrlRead($ifms) = "" Then
                MsgBox(1, "Error", "Please Enter An Ifms")
                ContinueLoop
            EndIf
            If GuiCtrlRead($s_cust) = "" Then
                MsgBox(1, "Error", "Please Enter A Site Contact Name")
                ContinueLoop
            EndIf
            If GuiCtrlRead($s_ph) = "" Then
                MsgBox(1, "Error", "Please Enter A Site Contact Number")
                ContinueLoop
            EndIf           
            $temp = WebIFMS($ifms)
            $manual_ovr = Not StringInStr($temp,"lwt") ;
            $ph = PR_Getsumm($temp)
            If $ph == 0 Then
                $error = "No CCID Or Incorrect Format."
                PR_errorbox($error)
                Exit
            EndIf
        
            $cust = PR_GetContact($temp)
        
            $type = PR_GetPrType($temp)
            
            $fault_type = PR_Type($type,$temp)
            If $fault_type[0] == 0 Then 
                $error = "Error With PR Type."
                PR_errorbox($error
            EndIf
    
            $oIE = _IECreate("https://serviceweb.otsrv1.com.au/Login.jsp",0,1)
            $pagecheck = _IEBodyReadText($oIE)
        
            If StringInStr($pagecheck,"Network Access Message") Then
                $error = "LOLS is Timing Out"
                _IEQuit($oIE)   
                PR_errorbox($error)
                Exit
            EndIf
            _IENavigate($oIE,"https://serviceweb.otsrv1.com.au/wss/home/serviceNumberInput")

            If StringInStr($pagecheck,"Network Access Message") Then
                $error = "LOLS is Timing Out"
                _IEQuit($oIE)   
                PR_errorbox($error)
                Exit
            Endif
            If CheckURL($oIE,"https://serviceweb.otsrv1.com.au/wss/home/serviceNumberInput",$ifms) Then ContinueLoop
        
            If StringInStr($pagecheck,"ownership") Or StringInStr($pagecheck,"otsrv1 maintained") Or StringInStr($pagecheck,"otsrv1 does not recognise") Or StringInStr($pagecheck,"Our records indicate")Then
                $error = "Service not owned"
                _IEQuit($oIE)   
                PR_errorbox($error)
                Exit
            EndIf
            $o_form = _IEFormGetCollection ($oIE, 0)
            $oQuery = _IEFormElementGetCollection ($o_form, 0)
            _IEFormElementSetValue ($oQuery, $ph)
            _IEFormSubmit ($o_form)
            If CheckURL($oIE,"https://serviceweb.otsrv1.com.au/wss/serviceNumberInput/caseSearch",$ifms) Then ContinueLoop
            $pagecheck = _IEBodyReadText($oIE)

            If StringInStr($pagecheck,"ownership") Or StringInStr($pagecheck,"otsrv1 maintained") Or StringInStr($pagecheck,"otsrv1 does not recognise") Or StringInStr($pagecheck,"Our records indicate")Then
                $error = "Service not owned"
                _IEQuit($oIE)   
                PR_errorbox($error)
                Exit
            EndIf

            If StringInStr($pagecheck,"OPTUS NETWORKS PTY LIMITED") Then
                $error = "ULL OPTUS NETWORKS PTY LIMITED"
                _IEQuit($oIE)   
                PR_errorbox($error)
                Exit
            EndIf

            If StringInStr($pagecheck,"active Cases listed against Service Number") Then 
                $error = "This Service has an Active case already logged"
                _IEQuit($oIE)   
                PR_errorbox($error)
                Exit
            EndIf   
        
            $o_form = _IEFormGetObjByName ($oIE, "f1")
            $o_ifms= _IEFormElementGetObjByName ($o_form, "CUSTOMER_REF_ID")
            $o_temp = _IEFormElementGetObjByName ($o_form, "NOTE")  


            _IEFormElementSetValue ($o_ifms, $ifms)         
            _IEFormElementSetValue ($o_temp, "Our isolation tests indicate that there are issues on the ULL. The end user is reporting that this service is completely down. Please investigate")

            _IEFormElementCheckBoxSelect($o_form,"on", "", 1, "byValue")
            _IEFormElementRadioSelect($o_form,"Workable","FAULT_IMPACT",1,"byValue")
            $o_cat = _IEFormElementGetObjByName ($o_form, "FAULT_CATEGORY")
            $o_sym = _IEFormElementGetObjByName ($o_form, "FAULT_SYMPTOM")
            _IEFormElementOptionselect($o_cat,"Problem with ADSL service",1,"byText")
    
            _IEFormElementOptionselect($o_sym,$fault_type[0],1,"byText")

            _IEFormImageClick ($oIE, "next.gif")
            If CheckURL($oIE,"https://serviceweb.otsrv1.com.au/wss/serviceDetails/next",$ifms) Then ContinueLoop
            $pagecheck = _IEBodyReadHTML($oIE)
            If StringInStr($pagecheck,"Network Access Message") Then
                $error = "LOLS is Timing Out"
                _IEQuit($oIE)   
                PR_errorbox($error)
                Exit
            Endif

            If StringInStr($pagecheck,"OutageInformation") Then
                    $error = "Outage effecting service"
                    _IEQuit($oIE)   
                PR_errorbox($error)
                Exit
            EndIf
            $o_form = _IEFormGetObjByName ($oIE, "formName")
            Call($fault_type[1],$o_form)
            _IEFormImageClick ($oIE, "next.gif")
            _IENavigate($oIE,"https://serviceweb.otsrv1.com.au/wss/CaseMgmtCentral/centralnext")

            If StringInStr($pagecheck,"Network Access Message") Then
                $error = "LOLS is Timing Out"
                _IEQuit($oIE)   
                PR_errorbox($error)
                Exit
            Endif
            $o_form = _IEFormGetObjByName ($oIE, "additionalDetails")
            $o_det = _IEFormElementGetObjByName ($o_form, "AdditionalDetails")
            _IEFormElementSetValue ($o_det, "N2000957K")
            _IEFormSubmit($o_form)  
            If CheckURL($oIE,"https://serviceweb.otsrv1.com.au/wss/additionalDetails/next",$ifms) Then ContinueLoop
            $o_form = _IEFormGetObjByName ($oIE, "myform")
            $o_cust= _IEFormElementGetObjByName ($o_form, "SiteFirstName")
            $o_custl = _IEFormElementGetObjByName ($o_form, "SiteLastName")
            $o_ph = _IEFormElementGetObjByName ($o_form, "SitePhone")
            $o_rep= _IEFormElementGetObjByName ($o_form, "ReportFirstName")
            $o_repl = _IEFormElementGetObjByName ($o_form, "ReportLastName")
            $repid = randomname()
            _IEFormElementSetValue ($o_rep, $repid[0])
            _IEFormElementSetValue ($o_repl, $repid[1])
            _IEFormElementSetValue ($o_custl, "n/a")

            _IEFormElementSetValue ($s_cust, $cust[1])
            _IEFormElementSetValue ($s_ph, $ph) 
            $o_clos = _IEFormElementGetObjByName($o_form,"ClosureNotification")
            _IEFormElementOptionselect($o_clos,$closure,1,"byText")
            $o_start = _IEFormElementGetObjByName($o_form,"SiteStartHours")
            _IEFormElementOptionselect($o_start,"08:00",1,"byValue")
            $o_end = _IEFormElementGetObjByName($o_form,"SiteEndHours")
            _IEFormElementOptionselect($o_end,"17:00",1,"byValue")

            _IEFormImageClick ($oIE, "next.gif")
            If CheckURL($oIE,"https://serviceweb.otsrv1.com.au/wss/contact/next",$ifms) Then ContinueLoop

            If StringInStr($pagecheck,"Network Access Message") Then
                $error = "LOLS is Timing Out"
                _IEQuit($oIE)   
                PR_errorbox($error)
                Exit
            Endif

            $oForm = _IEFormGetCollection ($oIE,0)
            _IEFormSubmit ($oForm)

            $submit = _IEBodyReadText ($oIE)

            _IEQuit($oIE)

            $pos1 = StringInStr($submit,"otsrv1 Case Reference Number:") + 31
            $tcase = StringMid($submit,$pos1,9)
            

            $pos1 = StringInStr($submit,"Target Restoration Date / Time:") + 32
            $tres = StringMid($submit,$pos1,19)

            $t_restoredate = PR_treference ($tres)
            LOLS($ifms,$tcase,$tres)
            $error_count = 0
            MsgBox(1, "Wilson", "This ticket has been logged and dispached.")
            ExitLooP
        EndSelect
    WEnd
Edited by autonoob

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
×
×
  • Create New...