Jump to content

Fields being sent incorrect data


Recommended Posts

Ok so I'm writing an AutoIT script to interact with a Javascript based form on this website http://www.nationwide-intermediary.co.uk/calculators/aff_calc

With the help of MichaelHB I've been successful in completing the whole form and obtaining a result using fixed values for entries to the form.

Now I'm at the stage where I'm replacing the fixed values with variables that are read into an array from a text file. However, despite using the same data as was previously hard coded and the same input method ['Send' as this is all that works] when I get to the second page of the form I am encountering a problem.

So the second page is about employment type and income details. If there are two applicants and they have the same employment type, then the form is completed correctly. However if the employment types differ (which would be common in reality) then there is a problem whereby despite my attempts to strip the irrelevant information, certain fields are missing figures and other fields end up containing multiple entries.

Below is the code up to the stage of the form where it breaks, I'll also attach the Data.txt file that is being read which needs to be in the same folder as the script if you wish to run it.

To change employment types change the text in Data.txt after the : for the relevant line with the corresponding text from section $EmpTypeOne and $EmpTypeTwo e.g. Employed, SEP, SEST, Director <20% S/H - remember to save the Data.txt file after making any changes so they are written to the file before being read by the script.

#include <IE.au3>
#include <Date.au3>
#include <File.au3>
#include <Array.au3>

$aArray = 0

If Not _FileReadToArray(@ScriptDir & "\Data.txt", $aArray) Then
    $SystemTime = _Date_Time_GetLocalTime()
    $CurrentTime = _Date_Time_SystemTimeToDateTimeStr($SystemTime)
    $Error = FileOpen(@ScriptDir & "\Error.txt", $FO_APPEND)
    FileWriteLine($Error, $CurrentTime & " - Couldn't open Data.txt file : Error " & @error)
   Exit
   EndIf

$BuyOrRemo = _ArrayToString($aArray, ":", 1, 1)
If StringInStr($BuyOrRemo, "Purchase") Then
   $BuyOrRemo = 1 ; Purchase
ElseIf StringInStr($BuyOrRemo, "Remortgage") Then
   $BuyOrRemo = 2 ; Remortgage
EndIf
ConsoleWrite($BuyOrRemo & @CRLF)

$MtgAmtRaw = _ArrayToString($aArray, ":", 2, 2)
$MtgAmtStart = StringInStr($MtgAmtRaw, ":")
$MtgAmt = StringMid($MtgAmtRaw, ($MtgAmtStart + 1), 8)
ConsoleWrite($MtgAmt & @CRLF)
$MtgTermYrsRaw = _ArrayToString($aArray, ":", 3, 3)
$MtgTermStart = StringInStr($MtgTermYrsRaw, ":")
$MtgTermYrs = StringMid($MtgTermYrsRaw, ($MtgTermStart + 1), 2)
ConsoleWrite($MtgTermYrs & @CRLF)
$MtgTermMthsRaw = _ArrayToString($aArray, ":", 4, 4)
$MtgTermMthsStart = StringInStr($MtgTermMthsRaw, ":")
$MtgTermMths = StringMid($MtgTermMthsRaw, ($MtgTermMthsStart + 1), 2)
ConsoleWrite($MtgTermMths & @CRLF)

$NumOfApplicants = _ArrayToString($aArray, ":", 5, 5)
If StringInStr($NumOfApplicants, "1") Then
   $NumOfApplicants = 3 ; One
ElseIf StringInStr($NumOfApplicants, "2") Then
   $NumOfApplicants = 4 ; Two
EndIf
ConsoleWrite($NumOfApplicants & @CRLF)

$OwnershipType = _ArrayToString($aArray, ":", 6, 6)
If StringInStr($OwnershipType, "Standard") Then
   $OwnershipType = 4 ; Standard
ElseIf StringInStr($OwnershipType, "Equity Share") Then
   $OwnershipType = 5 ; Equity Share
ElseIf StringInStr($OwnershipType, "Right To Buy") Then
   $OwnershipType = 6 ; Right to buy
ElseIf StringInStr($OwnershipType, "Shared Ownership") Then
   $OwnershipType = 7 ; Shared Ownership
EndIf
ConsoleWrite($OwnershipType & @CRLF)

$FoundProperty = _ArrayToString($aArray, ":", 7, 7)
If StringInStr($FoundProperty, "Yes") Then
   $FoundProperty = 5 ; Applicant(s) have found a property
ElseIf StringInStr($FoundProperty, "No") Then
   $FoundProperty = 6 ; Applicant(s) have not found a property
EndIf
ConsoleWrite($FoundProperty & @CRLF)

$Tenure = _ArrayToString($aArray, ":", 8, 8)
If StringInStr($Tenure, "Freehold") Then
   $Tenure = 9 ; Freehold
ElseIf StringInStr($Tenure, "Leasehold") Then
   $Tenure = 10 ; Leasehold
EndIf
ConsoleWrite($Tenure & @CRLF)

$PropType = _ArrayToString($aArray, ":", 9, 9)
If StringInStr($PropType, "Detached House") Then
   $PropType = 14 ; Detached House
ElseIf StringInStr($PropType, "Detached Bungalow") Then
   $PropType = 15 ; Detached Bungalow
ElseIf StringInStr($PropType, "Semi-Detached Bungalow") Then
   $PropType = 16 ; Semi-Detached Bungalow
ElseIf StringInStr($PropType, "Terraced Bungalow") Then
   $PropType = 17 ; Terraced Bungalow
ElseIf StringInStr($PropType, "Semi-Detached House") Then
   $PropType = 18 ; Semi-Detached House
ElseIf StringInStr($PropType, "Terraced House") Then
   $PropType = 19 ; Terraced House
ElseIf StringInStr($PropType, "Purpose-built Flat/Maisonette") Then
   $PropType = 20 ; Purpose-built Flat/Maisonette
ElseIf StringInStr($PropType, "Converted Flat/Maisonette") Then
   $PropType = 21 ; Converted Flat/Maisonette
EndIf
ConsoleWrite($PropType & @CRLF)

$PPRaw = _ArrayToString($aArray, ":", 10, 10)
$PPStart = StringInStr($PPRaw, ":")
$PP = StringMid($PPRaw, ($PPStart + 1), 8)
ConsoleWrite($PP & @CRLF)
$DOB1Raw = _ArrayToString($aArray, ":", 11, 11)
$DOB1Start = StringInStr($DOB1Raw, ":")
$DOB1 = StringMid($DOB1Raw, ($DOB1Start + 1), 8)
ConsoleWrite($DOB1 & @CRLF)
$DOB2Raw = _ArrayToString($aArray, ":", 12, 12)
$DOB2Start = StringInStr($DOB2Raw, ":")
$DOB2 = StringMid($DOB2Raw, ($DOB2Start + 1), 8)
ConsoleWrite($DOB2 & @CRLF)

$Gender1 = _ArrayToString($aArray, ":", 13, 13)
If StringInStr($Gender1, "M") Then
   $Gender1 = 1 ; 1 = Male
ElseIf StringInStr($Gender1, "F") Then
   $Gender1 = 2 ; 2 = Female
EndIf
ConsoleWrite($Gender1 & @CRLF)

$Gender2 = _ArrayToString($aArray, ":", 14, 14)
If StringInStr($Gender2, "M") Then
   $Gender2 = 4 ; 4 = Male
ElseIf StringInStr($Gender2, "F") Then
   $Gender2 = 5 ; 5 = Female
EndIf
ConsoleWrite($Gender2 & @CRLF)

$Dependents1 = _ArrayToString($aArray, ":", 15, 15)
If StringInStr($Dependents1, "Yes") Then
   $Dependents1 = 2 ; Has dependents
ElseIf StringInStr($Dependents1, "No") Then
   $Dependents1 = 3 ; No dependents
EndIf
ConsoleWrite($Dependents1 & @CRLF)

$Dependents2 = _ArrayToString($aArray, ":", 16, 16)
If StringInStr($Dependents2, "Yes") Then
   $Dependents2 = 4 ; Has dependents
ElseIf StringInStr($Dependents2, "No") Then
   $Dependents2 = 5 ; No dependents
EndIf
ConsoleWrite($Dependents2 & @CRLF)

$Deps11Result = _ArrayToString($aArray, ":", 17, 17)
$Deps1Start = StringInStr($Deps11Result, ":")
$Deps10To5 = StringMid($Deps11Result, ($Deps1Start + 1), 2)
ConsoleWrite($Deps10To5 & @CRLF)

$Deps12Result = _ArrayToString($aArray, ":", 18, 18)
$Deps1Start = StringInStr($Deps12Result, ":")
$Deps16To11 = StringMid($Deps12Result, ($Deps1Start + 1), 2)
ConsoleWrite($Deps16To11 & @CRLF)

$Deps13Result = _ArrayToString($aArray, ":", 19, 19)
$Deps1Start = StringInStr($Deps13Result, ":")
$Deps112To17 = StringMid($Deps13Result, ($Deps1Start + 1), 2)
ConsoleWrite($Deps112To17 & @CRLF)

$Deps14Result = _ArrayToString($aArray, ":", 20, 20)
$Deps1Start = StringInStr($Deps14Result, ":")
$Deps118Plus = StringMid($Deps14Result, ($Deps1Start + 1), 2)
ConsoleWrite($Deps118Plus & @CRLF)

$Deps21Result = _ArrayToString($aArray, ":", 21, 21)
$Deps2Start = StringInStr($Deps21Result, ":")
$Deps20To5 = StringMid($Deps21Result, ($Deps2Start + 1), 2)
ConsoleWrite($Deps20To5 & @CRLF)

$Deps22Result = _ArrayToString($aArray, ":", 22, 22)
$Deps2Start = StringInStr($Deps22Result, ":")
$Deps26To11 = StringMid($Deps22Result, ($Deps2Start + 1), 2)
ConsoleWrite($Deps26To11 & @CRLF)

$Deps23Result = _ArrayToString($aArray, ":", 23, 23)
$Deps2Start = StringInStr($Deps23Result, ":")
$Deps212To17 = StringMid($Deps23Result, ($Deps2Start + 1), 2)
ConsoleWrite($Deps212To17 & @CRLF)

$Deps24Result = _ArrayToString($aArray, ":", 24, 24)
$Deps2Start = StringInStr($Deps24Result, ":")
$Deps218Plus = StringMid($Deps24Result, ($Deps2Start + 1), 2)
ConsoleWrite($Deps218Plus & @CRLF)

$Retired1 = _ArrayToString($aArray, ":", 25, 25)
If StringInStr($Retired1, "Yes") Then
   $Retired1 = 14 ; 14 = Retired
ElseIf StringInStr($Retired1, "No") Then
   $Retired1 = 15 ; 15 = Not retired
EndIf
ConsoleWrite($Retired1 & @CRLF)

$Retired2 = _ArrayToString($aArray, ":", 26, 26)
If StringInStr($Retired2, "Yes") Then
   $Retired2 = 16 ; 16 = Retired
ElseIf StringInStr($Retired2, "No") Then
   $Retired2 = 17 ; 17 = Not retired
EndIf
ConsoleWrite($Retired2 & @CRLF)

$RetAge1Raw = _ArrayToString($aArray, ":", 27, 27)
$RetAge1Start = StringInStr($RetAge1Raw, ":")
$RetAge1 = StringMid($RetAge1Raw, ($RetAge1Start + 1), 2)
ConsoleWrite($RetAge1 & @CRLF)
$RetAge2Raw = _ArrayToString($aArray, ":", 28, 28)
$RetAge2Start = StringInStr($RetAge2Raw, ":")
$RetAge2 = StringMid($RetAge2Raw, ($RetAge2Start + 1), 2)
ConsoleWrite($RetAge2 & @CRLF)

$EmpTypeOne = _ArrayToString($aArray, ":", 29, 29)
if StringInStr($EmpTypeOne, "Unemployed") Then
   $EmpTypeOne = 9 ; Unemployed
ElseIf StringInStr($EmpTypeOne, "SEP") Then
   $EmpTypeOne = 2 ; Self-employed (parter)
ElseIf StringInStr($EmpTypeOne, "SEST") Then
   $EmpTypeOne = 3 ; Self-employed (sole trader)
ElseIf StringInStr($EmpTypeOne, "Director <20% S/H") Then
   $EmpTypeOne = 4 ; Director with less than a 20% share-holding
ElseIf StringInStr($EmpTypeOne, "Director =>20% S/H") Then
   $EmpTypeOne = 5 ; Director with equal to or more than 20% share-holding
ElseIf StringInStr($EmpTypeOne, "Retired") Then
   $EmpTypeOne = 6 ; Retired
ElseIf StringInStr($EmpTypeOne, "Homemaker") Then
   $EmpTypeOne = 7 ; Homemaker
ElseIf StringInStr($EmpTypeOne, "Student") Then
   $EmpTypeOne = 8 ; Student
ElseIf StringInStr($EmpTypeOne, "Employed") Then
   $EmpTypeOne = 1 ; Employed
EndIf
ConsoleWrite($EmpTypeOne & @CRLF)

$EmpTypeTwo = _ArrayToString($aArray, ":", 30, 30)
if StringInStr($EmpTypeTwo, "Unemployed") Then
   $EmpTypeTwo = 19 ; Unemployed
ElseIf StringInStr($EmpTypeTwo, "SEP") Then
   $EmpTypeTwo = 12 ; Self-employed (parter)
ElseIf StringInStr($EmpTypeTwo, "SEST") Then
   $EmpTypeTwo = 13 ; Self-employed (sole trader)
ElseIf StringInStr($EmpTypeTwo, "Director <20% S/H") Then
   $EmpTypeTwo = 14 ; Director with less than a 20% share-holding
ElseIf StringInStr($EmpTypeTwo, "Director =>20% S/H") Then
   $EmpTypeTwo = 15 ; Director with equal to or more than 20% share-holding
ElseIf StringInStr($EmpTypeTwo, "Retired") Then
   $EmpTypeTwo = 16 ; Retired
ElseIf StringInStr($EmpTypeTwo, "Homemaker") Then
   $EmpTypeTwo = 17 ; Homemaker
ElseIf StringInStr($EmpTypeTwo, "Student") Then
   $EmpTypeTwo = 18 ; Student
ElseIf StringInStr($EmpTypeTwo, "Employed") Then
   $EmpTypeTwo = 11 ; Employed
EndIf
ConsoleWrite($EmpTypeTwo & @CRLF)

$EmpTenureOne = _ArrayToString($aArray, ":", 31, 31)
if StringInStr($EmpTenureOne, "Permanent") Then
   $EmpTenureOne = 21 ; Permanent
ElseIf StringInStr($EmpTenureOne, "Fixed Term Contract") Then
   $EmpTenureOne = 22 ; Fixed Term Contract
ElseIf StringInStr($EmpTenureOne, "Sub-contractor (fixed term)") Then
   $EmpTenureOne = 23 ; Sub-contractor (fixed term)
ElseIf StringInStr($EmpTenureOne, "Sub-contractor (open ended)") Then
   $EmpTenureOne = 24 ; Sub-contractor (open ended)
ElseIf StringInStr($EmpTenureOne, "Temporary") Then
   $EmpTenureOne = 25 ; Temporary
EndIf
ConsoleWrite($EmpTenureOne & @CRLF)

$EmpTenureTwo = _ArrayToString($aArray, ":", 32, 32)
if StringInStr($EmpTenureTwo, "Permanent") Then
   $EmpTenureTwo = 27 ; Permanent
ElseIf StringInStr($EmpTenureTwo, "Fixed Term Contract") Then
   $EmpTenureTwo = 28 ; Fixed Term Contract
ElseIf StringInStr($EmpTenureTwo, "Sub-contractor (fixed term)") Then
   $EmpTenureTwo = 29 ; Sub-contractor (fixed term)
ElseIf StringInStr($EmpTenureTwo, "Sub-contractor (open ended)") Then
   $EmpTenureTwo = 30 ; Sub-contractor (open ended)
ElseIf StringInStr($EmpTenureTwo, "Temporary") Then
   $EmpTenureTwo = 31 ; Temporary
EndIf
ConsoleWrite($EmpTenureTwo & @CRLF)

$TreatedAsEmployedOne = _ArrayToString($aArray, ":", 33, 33)
If StringInStr($TreatedAsEmployedOne, "Yes") Then
   $TreatedAsEmployedOne = 0 ; Yes
ElseIf StringInStr($TreatedAsEmployedOne, "No") Then
   $TreatedAsEmployedOne = 1 ; No
EndIf
ConsoleWrite($TreatedAsEmployedOne & @CRLF)

$TreatedAsEmployedTwo = _ArrayToString($aArray, ":", 34, 34)
If StringInStr($TreatedAsEmployedTwo, "Yes") Then
   $TreatedAsEmployedTwo = 2 ; Yes
ElseIf StringInStr($TreatedAsEmployedTwo, "No") Then
   $TreatedAsEmployedTwo = 3 ; No
EndIf
ConsoleWrite($TreatedAsEmployedTwo & @CRLF)

$YrsInJobOneRaw = _ArrayToString($aArray, ":", 35, 35)
$YrsInJobOneStart = StringInStr($YrsInJobOneRaw, ":")
$YrsInJobOne = StringMid($YrsInJobOneRaw, ($YrsInJobOneStart + 1), 2)
ConsoleWrite($YrsInJobOne & @CRLF)
$MthsInJobOneRaw = _ArrayToString($aArray, ":", 36, 36)
$MthsInJobOneStart = StringInStr($MthsInJobOneRaw, ":")
$MthsInJobOne = StringMid($MthsInJobOneRaw, ($MthsInJobOneStart + 1), 2)
ConsoleWrite($MthsInJobOne & @CRLF)
$YrsInJobTwoRaw = _ArrayToString($aArray, ":", 37, 37)
$YrsInJobTwoStart = StringInStr($YrsInJobTwoRaw, ":")
$YrsInJobTwo = StringMid($YrsInJobTwoRaw, ($YrsInJobTwoStart + 1), 2)
ConsoleWrite($YrsInJobTwo & @CRLF)
$MthsInJobTwoRaw = _ArrayToString($aArray, ":", 38, 38)
$MthsInJobTwoStart = StringInStr($MthsInJobTwoRaw, ":")
$MthsInJobTwo = StringMid($MthsInJobTwoRaw, ($MthsInJobTwoStart + 1), 2)
ConsoleWrite($MthsInJobTwo & @CRLF)
$YrsRemOnContractOneRaw = _ArrayToString($aArray, ":", 39, 39)
$YrsRemOnContractOneStart = StringInStr($YrsRemOnContractOneRaw, ":")
$YrsRemOnContractOne = StringMid($YrsRemOnContractOneRaw, ($YrsRemOnContractOneStart + 1), 2)
ConsoleWrite($YrsRemOnContractOne & @CRLF)
$MthsRemOnContractOneRaw = _ArrayToString($aArray, ":", 40, 40)
$MthsRemOnContractOneStart = StringInStr($MthsRemOnContractOneRaw, ":")
$MthsRemOnContractOne = StringMid($MthsRemOnContractOneRaw, ($MthsRemOnContractOneStart + 1), 2)
ConsoleWrite($MthsRemOnContractOne & @CRLF)
$YrsRemOnContractTwoRaw = _ArrayToString($aArray, ":", 41, 41)
$YrsRemOnContractTwoStart = StringInStr($YrsRemOnContractTwoRaw, ":")
$YrsRemOnContractTwo = StringMid($YrsRemOnContractTwoRaw, ($YrsRemOnContractTwoStart + 1), 2)
ConsoleWrite($YrsRemOnContractTwo & @CRLF)
$MthsRemOnContractTwoRaw = _ArrayToString($aArray, ":", 42, 42)
$MthsRemOnContractTwoStart = StringInStr($MthsRemOnContractTwoRaw, ":")
$MthsRemOnContractTwo = StringMid($MthsRemOnContractTwoRaw, ($MthsRemOnContractTwoStart + 1), 2)
ConsoleWrite($MthsRemOnContractTwo & @CRLF)
$SalaryOneRaw = _ArrayToString($aArray, ":", 43, 43)
$SalaryOneStart = StringInStr($SalaryOneRaw, ":")
$SalaryOne = StringMid($SalaryOneRaw, ($SalaryOneStart + 1), 8)
ConsoleWrite($SalaryOne & @CRLF)
$SalaryTwoRaw = _ArrayToString($aArray, ":", 44, 44)
$SalaryTwoStart = StringInStr($SalaryTwoRaw, ":")
$SalaryTwo = StringMid($SalaryTwoRaw, ($SalaryTwoStart + 1), 8)
ConsoleWrite($SalaryTwo & @CRLF)
$BonusOneRaw = _ArrayToString($aArray, ":", 45, 45)
$BonusOneStart = StringInStr($BonusOneRaw, ":")
$BonusOne = StringMid($BonusOneRaw, ($BonusOneStart + 1), 8)
ConsoleWrite($BonusOne & @CRLF)
$BonusTwoRaw = _ArrayToString($aArray, ":", 46, 46)
$BonusTwoStart = StringInStr($BonusTwoRaw, ":")
$BonusTwo = StringMid($BonusTwoRaw, ($BonusTwoStart + 1), 8)
ConsoleWrite($BonusTwo & @CRLF)
$OvertimeOneRaw = _ArrayToString($aArray, ":", 47, 47)
$OvertimeOneStart = StringInStr($OvertimeOneRaw, ":")
$OvertimeOne = StringMid($OvertimeOneRaw, ($OvertimeOneStart + 1), 8)
ConsoleWrite($OvertimeOne & @CRLF)
$OvertimeTwoRaw = _ArrayToString($aArray, ":", 48, 48)
$OvertimeTwoStart = StringInStr($OvertimeTwoRaw, ":")
$OvertimeTwo = StringMid($OvertimeTwoRaw, ($OvertimeTwoStart + 1), 8)
ConsoleWrite($OvertimeTwo & @CRLF)
$CommissionOneRaw = _ArrayToString($aArray, ":", 49, 49)
$CommissionOneStart = StringInStr($CommissionOneRaw, ":")
$CommissionOne = StringMid($CommissionOneRaw, ($CommissionOneStart + 1), 8)
ConsoleWrite($CommissionOne & @CRLF)
$CommissionTwoRaw = _ArrayToString($aArray, ":", 50, 50)
$CommissionTwoStart = StringInStr($CommissionTwoRaw, ":")
$CommissionTwo = StringMid($CommissionTwoRaw, ($CommissionTwoStart + 1), 8)
ConsoleWrite($CommissionTwo & @CRLF)
$NetPreTaxProfitLatestYrOneRaw = _ArrayToString($aArray, ":", 51, 51)
$NetPreTaxProfitLatestYrOneStart = StringInStr($NetPreTaxProfitLatestYrOneRaw, ":")
$NetPreTaxProfitLatestYrOne = StringMid($NetPreTaxProfitLatestYrOneRaw, ($NetPreTaxProfitLatestYrOneStart + 1), 8)
ConsoleWrite($NetPreTaxProfitLatestYrOne & @CRLF)
$NetPreTaxProfitLatestYrTwoRaw = _ArrayToString($aArray, ":", 52, 52)
$NetPreTaxProfitLatestYrTwoStart = StringInStr($NetPreTaxProfitLatestYrTwoRaw, ":")
$NetPreTaxProfitLatestYrTwo = StringMid($NetPreTaxProfitLatestYrTwoRaw, ($NetPreTaxProfitLatestYrTwoStart + 1), 8)
ConsoleWrite($NetPreTaxProfitLatestYrTwo & @CRLF)
$NetPreTaxProfitPrevYrOneRaw = _ArrayToString($aArray, ":", 53, 53)
$NetPreTaxProfitPrevYrOneStart = StringInStr($NetPreTaxProfitPrevYrOneRaw, ":")
$NetPreTaxProfitPrevYrOne = StringMid($NetPreTaxProfitPrevYrOneRaw, ($NetPreTaxProfitPrevYrOneStart + 1), 8)
ConsoleWrite($NetPreTaxProfitPrevYrOne & @CRLF)
$NetPreTaxProfitPrevYrTwoRaw = _ArrayToString($aArray, ":", 54, 54)
$NetPreTaxProfitPrevYrTwoStart = StringInStr($NetPreTaxProfitPrevYrTwoRaw, ":")
$NetPreTaxProfitPrevYrTwo = StringMid($NetPreTaxProfitPrevYrTwoRaw, ($NetPreTaxProfitPrevYrTwoStart + 1), 8)
ConsoleWrite($NetPreTaxProfitPrevYrTwo & @CRLF)
$ShareOfNetPreTaxProfitLatestYrOneRaw = _ArrayToString($aArray, ":", 55, 55)
$ShareOfNetPreTaxProfitLatestYrOneStart = StringInStr($ShareOfNetPreTaxProfitLatestYrOneRaw, ":")
$ShareOfNetPreTaxProfitLatestYrOne = StringMid($ShareOfNetPreTaxProfitLatestYrOneRaw, ($ShareOfNetPreTaxProfitLatestYrOneStart + 1), 8)
ConsoleWrite($ShareOfNetPreTaxProfitLatestYrOne & @CRLF)
$ShareOfNetPreTaxProfitPrevYrOneRaw = _ArrayToString($aArray, ":", 56, 56)
$ShareOfNetPreTaxProfitPrevYrOneStart = StringInStr($ShareOfNetPreTaxProfitPrevYrOneRaw, ":")
$ShareOfNetPreTaxProfitPrevYrOne = StringMid($ShareOfNetPreTaxProfitPrevYrOneRaw, ($ShareOfNetPreTaxProfitPrevYrOneStart + 1), 8)
ConsoleWrite($ShareOfNetPreTaxProfitPrevYrOne & @CRLF)
$ShareOfNetPreTaxProfitLatestYrTwoRaw = _ArrayToString($aArray, ":", 57, 57)
$ShareOfNetPreTaxProfitLatestYrTwoStart = StringInStr($ShareOfNetPreTaxProfitLatestYrTwoRaw, ":")
$ShareOfNetPreTaxProfitLatestYrTwo = StringMid($ShareOfNetPreTaxProfitLatestYrTwoRaw, ($ShareOfNetPreTaxProfitLatestYrTwoStart + 1), 8)
ConsoleWrite($ShareOfNetPreTaxProfitLatestYrTwo & @CRLF)
$ShareOfNetPreTaxProfitPrevYrTwoRaw = _ArrayToString($aArray, ":", 58, 58)
$ShareOfNetPreTaxProfitPrevYrTwoStart = StringInStr($ShareOfNetPreTaxProfitPrevYrTwoRaw, ":")
$ShareOfNetPreTaxProfitPrevYrTwo = StringMid($ShareOfNetPreTaxProfitPrevYrTwoRaw, ($ShareOfNetPreTaxProfitPrevYrTwoStart + 1), 8)
ConsoleWrite($ShareOfNetPreTaxProfitPrevYrTwo & @CRLF)
$SalaryPlusDividendsLatestYrOneRaw = _ArrayToString($aArray, ":", 59, 59)
$SalaryPlusDividendsLatestYrOneStart = StringInStr($SalaryPlusDividendsLatestYrOneRaw, ":")
$SalaryPlusDividendsLatestYrOne = StringMid($SalaryPlusDividendsLatestYrOneRaw, ($SalaryPlusDividendsLatestYrOneStart + 1), 8)
ConsoleWrite($SalaryPlusDividendsLatestYrOne & @CRLF)
$SalaryPlusDividendsPrevYrOneRaw = _ArrayToString($aArray, ":", 60, 60)
$SalaryPlusDividendsPrevYrOneStart = StringInStr($SalaryPlusDividendsPrevYrOneRaw, ":")
$SalaryPlusDividendsPrevYrOne = StringMid($SalaryPlusDividendsPrevYrOneRaw, ($SalaryPlusDividendsPrevYrOneStart + 1), 8)
ConsoleWrite($SalaryPlusDividendsPrevYrOne & @CRLF)
$SalaryPlusDividendsLatestYrTwoRaw = _ArrayToString($aArray, ":", 61, 61)
$SalaryPlusDividendsLatestYrTwoStart = StringInStr($SalaryPlusDividendsLatestYrTwoRaw, ":")
$SalaryPlusDividendsLatestYrTwo = StringMid($SalaryPlusDividendsLatestYrTwoRaw, ($SalaryPlusDividendsLatestYrTwoStart + 1), 8)
ConsoleWrite($SalaryPlusDividendsLatestYrTwo & @CRLF)
$SalaryPlusDividendsPrevYrTwoRaw = _ArrayToString($aArray, ":", 62, 62)
$SalaryPlusDividendsPrevYrTwoStart = StringInStr($SalaryPlusDividendsPrevYrTwoRaw, ":")
$SalaryPlusDividendsPrevYrTwo = StringMid($SalaryPlusDividendsPrevYrTwoRaw, ($SalaryPlusDividendsPrevYrTwoStart + 1), 8)
ConsoleWrite($SalaryPlusDividendsPrevYrTwo & @CRLF)

$SecondJobOne = _ArrayToString($aArray, ":", 63, 63)
If StringInStr($SecondJobOne, "Yes") Then
   $SecondJobOne = 32 ; Yes
ElseIf StringInStr($SecondJobOne, "No") Then
   $SecondJobOne = 33 ; No
EndIf
ConsoleWrite($SecondJobOne & @CRLF)

$SecondJobTwo = _ArrayToString($aArray, ":", 64, 64)
If StringInStr($SecondJobTwo, "Yes") Then
   $SecondJobTwo = 34 ; Yes
ElseIf StringInStr($SecondJobTwo, "No") Then
   $SecondJobTwo = 35 ; No
EndIf
ConsoleWrite($SecondJobTwo & @CRLF)

If $EmpTypeOne = 5 Then
   ;MsgBox(1, "Information", "Applicant 1 is a Director =>20%")
   $SalaryOne = ""
;   $SalaryTwo = ""
   $BonusOne = ""
;   $BonusTwo = ""
   $OvertimeOne = ""
;   $OvertimeTwo = ""
   $CommissionOne = ""
;   $CommissionTwo = ""
   $NetPreTaxProfitLatestYrOne = ""
;   $NetPreTaxProfitLatestYrTwo = ""
   $NetPreTaxProfitPrevYrOne = ""
;   $NetPreTaxProfitPrevYrTwo = ""
   $ShareOfNetPreTaxProfitLatestYrOne = ""
   $ShareOfNetPreTaxProfitPrevYrOne = ""
;   $ShareOfNetPreTaxProfitLatestYrTwo = ""
;   $ShareOfNetPreTaxProfitPrevYrTwo = ""
;DoTheBusiness()
EndIf

If $EmpTypeTwo = 15 Then
   ;MsgBox(1, "Information", "Applicant 2 is a Director =>20%")
;   $SalaryOne = ""
   $SalaryTwo = ""
;   $BonusOne = ""
   $BonusTwo = ""
;   $OvertimeOne = ""
   $OvertimeTwo = ""
;   $CommissionOne = ""
   $CommissionTwo = ""
;   $NetPreTaxProfitLatestYrOne = ""
   $NetPreTaxProfitLatestYrTwo = ""
;   $NetPreTaxProfitPrevYrOne = ""
   $NetPreTaxProfitPrevYrTwo = ""
;   $ShareOfNetPreTaxProfitLatestYrOne = ""
;   $ShareOfNetPreTaxProfitPrevYrOne = ""
   $ShareOfNetPreTaxProfitLatestYrTwo = ""
   $ShareOfNetPreTaxProfitPrevYrTwo = ""
  ; DoTheBusiness()
EndIf

If $EmpTypeTwo = 13 Then
   ;MsgBox(1, "Information", "Applicant 2 is a Self-employed (sole trader)")
;   $SalaryOne = ""
   $SalaryTwo = ""
;   $BonusOne = ""
   $BonusTwo = ""
;   $OvertimeOne = ""
   $OvertimeTwo = ""
;   $CommissionOne = ""
   $CommissionTwo = ""
;   $ShareOfNetPreTaxProfitLatestYrOne = ""
;   $ShareOfNetPreTaxProfitPrevYrOne = ""
   $ShareOfNetPreTaxProfitLatestYrTwo = ""
   $ShareOfNetPreTaxProfitPrevYrTwo = ""
;   $SalaryPlusDividendsLatestYrOne = ""
;   $SalaryPlusDividendsPrevYrOne = ""
   $SalaryPlusDividendsLatestYrTwo = ""
   $SalaryPlusDividendsPrevYrTwo = ""
 ;  DoTheBusiness()
EndIf

If $EmpTypeOne = 3 Then
   ;MsgBox(1, "Information", "Applicant 1 is a Self-employed (sole-trader)")
   $SalaryOne = ""
;   $SalaryTwo = ""
   $BonusOne = ""
;   $BonusTwo = ""
   $OvertimeOne = ""
;   $OvertimeTwo = ""
   $CommissionOne = ""
;   $CommissionTwo = ""
   $ShareOfNetPreTaxProfitLatestYrOne = ""
   $ShareOfNetPreTaxProfitPrevYrOne = ""
;   $ShareOfNetPreTaxProfitLatestYrTwo = ""
;   $ShareOfNetPreTaxProfitPrevYrTwo = ""
   $SalaryPlusDividendsLatestYrOne = ""
   $SalaryPlusDividendsPrevYrOne = ""
;   $SalaryPlusDividendsLatestYrTwo = ""
;   $SalaryPlusDividendsPrevYrTwo = ""
;DoTheBusiness()
EndIf

If $EmpTypeOne = 2 Then
   ;MsgBox(1, "Information", "Applicant 2 is a Self-employed (partner)")
   $SalaryOne = ""
;   $SalaryTwo = ""
   $BonusOne = ""
;   $BonusTwo = ""
   $OvertimeOne = ""
;   $OvertimeTwo = ""
   $CommissionOne = ""
;   $CommissionTwo = ""
   $NetPreTaxProfitLatestYrOne = ""
;   $NetPreTaxProfitLatestYrTwo = ""
   $NetPreTaxProfitPrevYrOne = ""
;   $NetPreTaxProfitPrevYrTwo = ""
   $SalaryPlusDividendsLatestYrOne = ""
   $SalaryPlusDividendsPrevYrOne = ""
;   $SalaryPlusDividendsLatestYrTwo = ""
;   $SalaryPlusDividendsPrevYrTwo = ""
;DoTheBusiness()
EndIf

If $EmpTypeTwo = 12 Then
   ;MsgBox(1, "Information", "Applicant 2 is a Self-employed (partner)")
;   $SalaryOne = ""
   $SalaryTwo = ""
;   $BonusOne = ""
   $BonusTwo = ""
;   $OvertimeOne = ""
   $OvertimeTwo = ""
;   $CommissionOne = ""
   $CommissionTwo = ""
;   $NetPreTaxProfitLatestYrOne = ""
   $NetPreTaxProfitLatestYrTwo = ""
;   $NetPreTaxProfitPrevYrOne = ""
   $NetPreTaxProfitPrevYrTwo = ""
;   $SalaryPlusDividendsLatestYrOne = ""
;   $SalaryPlusDividendsPrevYrOne = ""
   $SalaryPlusDividendsLatestYrTwo = ""
   $SalaryPlusDividendsPrevYrTwo = ""
;   DoTheBusiness()
EndIf

If $EmpTypeOne = 1 Then
   ;MsgBox(1, "Information", "Applicant 1 is Employed")
   $NetPreTaxProfitLatestYrOne = ""
   $NetPreTaxProfitLatestYrTwo = ""
   $NetPreTaxProfitPrevYrOne = ""
   $NetPreTaxProfitPrevYrTwo = ""
   $ShareOfNetPreTaxProfitLatestYrOne = ""
   $ShareOfNetPreTaxProfitLatestYrTwo = ""
   $ShareOfNetPreTaxProfitPrevYrOne = ""
   $ShareOfNetPreTaxProfitPrevYrTwo = ""
   $SalaryPlusDividendsLatestYrOne = ""
   $SalaryPlusDividendsLatestYrTwo = ""
   $SalaryPlusDividendsPrevYrOne = ""
   $SalaryPlusDividendsPrevYrTwo = ""
 ;  DoTheBusiness()
ElseIf $EmpTypeOne = 4 Then
   ;MsgBox(1, "Information", "Applicant 1 is a Director <=20% share-holding")
   $NetPreTaxProfitLatestYrOne = ""
   $NetPreTaxProfitLatestYrTwo = ""
   $NetPreTaxProfitPrevYrOne = ""
   $NetPreTaxProfitPrevYrTwo = ""
   $ShareOfNetPreTaxProfitLatestYrOne = ""
   $ShareOfNetPreTaxProfitLatestYrTwo = ""
   $ShareOfNetPreTaxProfitPrevYrOne = ""
   $ShareOfNetPreTaxProfitPrevYrTwo = ""
   $SalaryPlusDividendsLatestYrOne = ""
   $SalaryPlusDividendsLatestYrTwo = ""
   $SalaryPlusDividendsPrevYrOne = ""
   $SalaryPlusDividendsPrevYrTwo = ""
 ;  DoTheBusiness()
EndIf

If $EmpTypeTwo = 11 Then
   ;MsgBox(1, "Information", "Applicant 2 is Employed")
   $NetPreTaxProfitLatestYrOne = ""
   $NetPreTaxProfitLatestYrTwo = ""
   $NetPreTaxProfitPrevYrOne = ""
   $NetPreTaxProfitPrevYrTwo = ""
   $ShareOfNetPreTaxProfitLatestYrOne = ""
   $ShareOfNetPreTaxProfitLatestYrTwo = ""
   $ShareOfNetPreTaxProfitPrevYrOne = ""
   $ShareOfNetPreTaxProfitPrevYrTwo = ""
   $SalaryPlusDividendsLatestYrOne = ""
   $SalaryPlusDividendsLatestYrTwo = ""
   $SalaryPlusDividendsPrevYrOne = ""
   $SalaryPlusDividendsPrevYrTwo = ""
  ; DoTheBusiness()
ElseIf $EmpTypeTwo = 14 Then
   ;MsgBox(1, "Information", "Applicant 2 is a Director <=20% share-holding")
   $NetPreTaxProfitLatestYrOne = ""
   $NetPreTaxProfitLatestYrTwo = ""
   $NetPreTaxProfitPrevYrOne = ""
   $NetPreTaxProfitPrevYrTwo = ""
   $ShareOfNetPreTaxProfitLatestYrOne = ""
   $ShareOfNetPreTaxProfitLatestYrTwo = ""
   $ShareOfNetPreTaxProfitPrevYrOne = ""
   $ShareOfNetPreTaxProfitPrevYrTwo = ""
   $SalaryPlusDividendsLatestYrOne = ""
   $SalaryPlusDividendsLatestYrTwo = ""
   $SalaryPlusDividendsPrevYrOne = ""
   $SalaryPlusDividendsPrevYrTwo = ""
 ;  DoTheBusiness()
EndIf

If $EmpTypeOne = 9 Then
   ;MsgBox(1, "Information", "Applicant 1 is Unemployed")
   $SalaryOne = ""
;   $SalaryTwo = ""
   $BonusOne = ""
;   $BonusTwo = ""
   $OvertimeOne = ""
;   $OvertimeTwo = ""
   $CommissionOne = ""
;   $CommissionTwo = ""
   $NetPreTaxProfitLatestYrOne = ""
;   $NetPreTaxProfitLatestYrTwo = ""
   $NetPreTaxProfitPrevYrOne = ""
;   $NetPreTaxProfitPrevYrTwo = ""
   $ShareOfNetPreTaxProfitLatestYrOne = ""
   $ShareOfNetPreTaxProfitPrevYrOne = ""
;   $ShareOfNetPreTaxProfitLatestYrTwo = ""
;   $ShareOfNetPreTaxProfitPrevYrTwo = ""
   $SalaryPlusDividendsLatestYrOne = ""
   $SalaryPlusDividendsPrevYrOne = ""
;   $SalaryPlusDividendsLatestYrTwo = ""
;   $SalaryPlusDividendsPrevYrTwo = ""
   $SecondJobOne = 33
;   $SecondJobTwo = 35
   $SecondJobTypeOne = ""
;   $SecondJobTypeTwo = ""
   $SecondJobTenureOne = ""
;   $SecondJobTenureTwo = ""
   $TreatedAsEmployedOne = ""
;   $TreatedAsEmployedTwo = ""
   $YrsIn2ndJobOne = ""
   $MthsIn2ndJobOne = ""
;   $YrsIn2ndJobTwo = ""
;   $MthsIn2ndJobTwo = ""
   $YrsRemOn2ndJobContractOne = ""
   $MthsRemOn2ndJobContractOne = ""
;   $YrsRemOn2ndJobContractTwo = ""
;   $MthsRemOn2ndJobContractTwo = ""
   $SecondSalaryOne = ""
;   $SecondSalaryTwo = ""
   $SecondBonusOne = ""
;   $SecondBonusTwo = ""
   $SecondOvertimeOne = ""
;   $SecondOvertimeTwo = ""
   $SecondCommissionOne = ""
;   $SecondCommissionTwo = ""
   $SecondNetPreTaxProfitLatestYrOne = ""
;   $SecondNetPreTaxProfitLatestYrTwo = ""
   $SecondNetPreTaxProfitPrevYrOne = ""
;   $SecondNetPreTaxProfitPrevYrTwo = ""
;DoTheBusiness()
EndIf

If $EmpTypeTwo = 19 Then
   ;MsgBox(1, "Information", "Applicant 2 is Unemployed")
;   $SalaryOne = ""
   $SalaryTwo = ""
;   $BonusOne = ""
   $BonusTwo = ""
;   $OvertimeOne = ""
   $OvertimeTwo = ""
;   $CommissionOne = ""
   $CommissionTwo = ""
;   $NetPreTaxProfitLatestYrOne = ""
   $NetPreTaxProfitLatestYrTwo = ""
;   $NetPreTaxProfitPrevYrOne = ""
   $NetPreTaxProfitPrevYrTwo = ""
;   $ShareOfNetPreTaxProfitLatestYrOne = ""
;   $ShareOfNetPreTaxProfitPrevYrOne = ""
   $ShareOfNetPreTaxProfitLatestYrTwo = ""
   $ShareOfNetPreTaxProfitPrevYrTwo = ""
;   $SalaryPlusDividendsLatestYrOne = ""
;   $SalaryPlusDividendsPrevYrOne = ""
   $SalaryPlusDividendsLatestYrTwo = ""
   $SalaryPlusDividendsPrevYrTwo = ""
;   $SecondJobOne = 33
   $SecondJobTwo = 35
;   $SecondJobTypeOne = ""
   $SecondJobTypeTwo = ""
;   $SecondJobTenureOne = ""
   $SecondJobTenureTwo = ""
;   $TreatedAsEmployedOne = ""
   $TreatedAsEmployedTwo = ""
;   $YrsIn2ndJobOne = ""
;   $MthsIn2ndJobOne = ""
   $YrsIn2ndJobTwo = ""
   $MthsIn2ndJobTwo = ""
;   $YrsRemOn2ndJobContractOne = ""
;   $MthsRemOn2ndJobContractOne = ""
   $YrsRemOn2ndJobContractTwo = ""
   $MthsRemOn2ndJobContractTwo = ""
;   $SecondSalaryOne = ""
   $SecondSalaryTwo = ""
;   $SecondBonusOne = ""
   $SecondBonusTwo = ""
;   $SecondOvertimeOne = ""
   $SecondOvertimeTwo = ""
;   $SecondCommissionOne = ""
   $SecondCommissionTwo = ""
;   $SecondNetPreTaxProfitLatestYrOne = ""
   $SecondNetPreTaxProfitLatestYrTwo = ""
;   $SecondNetPreTaxProfitPrevYrOne = ""
   $SecondNetPreTaxProfitPrevYrTwo = ""
   ;DoTheBusiness()
EndIf

If $EmpTypeOne = 8 Then
   ;MsgBox(1, "Information", "Applicant 1 is a Student")
   $SalaryOne = ""
;   $SalaryTwo = ""
   $BonusOne = ""
;   $BonusTwo = ""
   $OvertimeOne = ""
;   $OvertimeTwo = ""
   $CommissionOne = ""
;   $CommissionTwo = ""
   $NetPreTaxProfitLatestYrOne = ""
;   $NetPreTaxProfitLatestYrTwo = ""
   $NetPreTaxProfitPrevYrOne = ""
;   $NetPreTaxProfitPrevYrTwo = ""
   $ShareOfNetPreTaxProfitLatestYrOne = ""
   $ShareOfNetPreTaxProfitPrevYrOne = ""
;   $ShareOfNetPreTaxProfitLatestYrTwo = ""
;   $ShareOfNetPreTaxProfitPrevYrTwo = ""
   $SalaryPlusDividendsLatestYrOne = ""
   $SalaryPlusDividendsPrevYrOne = ""
;   $SalaryPlusDividendsLatestYrTwo = ""
;   $SalaryPlusDividendsPrevYrTwo = ""
   $SecondJobOne = 33
;   $SecondJobTwo = 35
   $SecondJobTypeOne = ""
;   $SecondJobTypeTwo = ""
   $SecondJobTenureOne = ""
;   $SecondJobTenureTwo = ""
   $TreatedAsEmployedOne = ""
;   $TreatedAsEmployedTwo = ""
   $YrsIn2ndJobOne = ""
   $MthsIn2ndJobOne = ""
;   $YrsIn2ndJobTwo = ""
;   $MthsIn2ndJobTwo = ""
   $YrsRemOn2ndJobContractOne = ""
   $MthsRemOn2ndJobContractOne = ""
;   $YrsRemOn2ndJobContractTwo = ""
;   $MthsRemOn2ndJobContractTwo = ""
   $SecondSalaryOne = ""
;   $SecondSalaryTwo = ""
   $SecondBonusOne = ""
;   $SecondBonusTwo = ""
   $SecondOvertimeOne = ""
;   $SecondOvertimeTwo = ""
   $SecondCommissionOne = ""
;   $SecondCommissionTwo = ""
   $SecondNetPreTaxProfitLatestYrOne = ""
;   $SecondNetPreTaxProfitLatestYrTwo = ""
   $SecondNetPreTaxProfitPrevYrOne = ""
;   $SecondNetPreTaxProfitPrevYrTwo = ""
;DoTheBusiness()
EndIf

If $EmpTypeTwo = 18 Then
   ;MsgBox(1, "Information", "Applicant 2 is a Student")
;   $SalaryOne = ""
   $SalaryTwo = ""
;   $BonusOne = ""
   $BonusTwo = ""
;   $OvertimeOne = ""
   $OvertimeTwo = ""
;   $CommissionOne = ""
   $CommissionTwo = ""
;   $NetPreTaxProfitLatestYrOne = ""
   $NetPreTaxProfitLatestYrTwo = ""
;   $NetPreTaxProfitPrevYrOne = ""
   $NetPreTaxProfitPrevYrTwo = ""
;   $ShareOfNetPreTaxProfitLatestYrOne = ""
;   $ShareOfNetPreTaxProfitPrevYrOne = ""
   $ShareOfNetPreTaxProfitLatestYrTwo = ""
   $ShareOfNetPreTaxProfitPrevYrTwo = ""
;   $SalaryPlusDividendsLatestYrOne = ""
;   $SalaryPlusDividendsPrevYrOne = ""
   $SalaryPlusDividendsLatestYrTwo = ""
   $SalaryPlusDividendsPrevYrTwo = ""
;   $SecondJobOne = 33
   $SecondJobTwo = 35
;   $SecondJobTypeOne = ""
   $SecondJobTypeTwo = ""
;   $SecondJobTenureOne = ""
   $SecondJobTenureTwo = ""
;   $TreatedAsEmployedOne = ""
   $TreatedAsEmployedTwo = ""
;   $YrsIn2ndJobOne = ""
;   $MthsIn2ndJobOne = ""
   $YrsIn2ndJobTwo = ""
   $MthsIn2ndJobTwo = ""
;   $YrsRemOn2ndJobContractOne = ""
;   $MthsRemOn2ndJobContractOne = ""
   $YrsRemOn2ndJobContractTwo = ""
   $MthsRemOn2ndJobContractTwo = ""
;   $SecondSalaryOne = ""
   $SecondSalaryTwo = ""
;   $SecondBonusOne = ""
   $SecondBonusTwo = ""
;   $SecondOvertimeOne = ""
   $SecondOvertimeTwo = ""
;   $SecondCommissionOne = ""
   $SecondCommissionTwo = ""
;   $SecondNetPreTaxProfitLatestYrOne = ""
   $SecondNetPreTaxProfitLatestYrTwo = ""
;   $SecondNetPreTaxProfitPrevYrOne = ""
   $SecondNetPreTaxProfitPrevYrTwo = ""
  ; DoTheBusiness()
EndIf

If $EmpTypeOne = 7 Then
   ;MsgBox(1, "Information", "Applicant 1 is a Homemaker")
   $SalaryOne = ""
;   $SalaryTwo = ""
   $BonusOne = ""
;   $BonusTwo = ""
   $OvertimeOne = ""
;   $OvertimeTwo = ""
   $CommissionOne = ""
;   $CommissionTwo = ""
   $NetPreTaxProfitLatestYrOne = ""
;   $NetPreTaxProfitLatestYrTwo = ""
   $NetPreTaxProfitPrevYrOne = ""
;   $NetPreTaxProfitPrevYrTwo = ""
   $ShareOfNetPreTaxProfitLatestYrOne = ""
   $ShareOfNetPreTaxProfitPrevYrOne = ""
;   $ShareOfNetPreTaxProfitLatestYrTwo = ""
;   $ShareOfNetPreTaxProfitPrevYrTwo = ""
   $SalaryPlusDividendsLatestYrOne = ""
   $SalaryPlusDividendsPrevYrOne = ""
;   $SalaryPlusDividendsLatestYrTwo = ""
;   $SalaryPlusDividendsPrevYrTwo = ""
   $SecondJobOne = 33
;   $SecondJobTwo = 35
   $SecondJobTypeOne = ""
;   $SecondJobTypeTwo = ""
   $SecondJobTenureOne = ""
;   $SecondJobTenureTwo = ""
   $TreatedAsEmployedOne = ""
;   $TreatedAsEmployedTwo = ""
   $YrsIn2ndJobOne = ""
   $MthsIn2ndJobOne = ""
;   $YrsIn2ndJobTwo = ""
;   $MthsIn2ndJobTwo = ""
   $YrsRemOn2ndJobContractOne = ""
   $MthsRemOn2ndJobContractOne = ""
;   $YrsRemOn2ndJobContractTwo = ""
;   $MthsRemOn2ndJobContractTwo = ""
   $SecondSalaryOne = ""
;   $SecondSalaryTwo = ""
   $SecondBonusOne = ""
;   $SecondBonusTwo = ""
   $SecondOvertimeOne = ""
;   $SecondOvertimeTwo = ""
   $SecondCommissionOne = ""
;   $SecondCommissionTwo = ""
   $SecondNetPreTaxProfitLatestYrOne = ""
;   $SecondNetPreTaxProfitLatestYrTwo = ""
   $SecondNetPreTaxProfitPrevYrOne = ""
;   $SecondNetPreTaxProfitPrevYrTwo = ""
;DoTheBusiness()
EndIf

If $EmpTypeTwo = 17 Then
   ;MsgBox(1, "Information", "Applicant 2 is a Homemaker")
;   $SalaryOne = ""
   $SalaryTwo = ""
;   $BonusOne = ""
   $BonusTwo = ""
;   $OvertimeOne = ""
   $OvertimeTwo = ""
;   $CommissionOne = ""
   $CommissionTwo = ""
;   $NetPreTaxProfitLatestYrOne = ""
   $NetPreTaxProfitLatestYrTwo = ""
;   $NetPreTaxProfitPrevYrOne = ""
   $NetPreTaxProfitPrevYrTwo = ""
;   $ShareOfNetPreTaxProfitLatestYrOne = ""
;   $ShareOfNetPreTaxProfitPrevYrOne = ""
   $ShareOfNetPreTaxProfitLatestYrTwo = ""
   $ShareOfNetPreTaxProfitPrevYrTwo = ""
;   $SalaryPlusDividendsLatestYrOne = ""
;   $SalaryPlusDividendsPrevYrOne = ""
   $SalaryPlusDividendsLatestYrTwo = ""
   $SalaryPlusDividendsPrevYrTwo = ""
;   $SecondJobOne = 33
   $SecondJobTwo = 35
;   $SecondJobTypeOne = ""
   $SecondJobTypeTwo = ""
;   $SecondJobTenureOne = ""
   $SecondJobTenureTwo = ""
;   $TreatedAsEmployedOne = ""
   $TreatedAsEmployedTwo = ""
;   $YrsIn2ndJobOne = ""
;   $MthsIn2ndJobOne = ""
   $YrsIn2ndJobTwo = ""
   $MthsIn2ndJobTwo = ""
;   $YrsRemOn2ndJobContractOne = ""
;   $MthsRemOn2ndJobContractOne = ""
   $YrsRemOn2ndJobContractTwo = ""
   $MthsRemOn2ndJobContractTwo = ""
;   $SecondSalaryOne = ""
   $SecondSalaryTwo = ""
;   $SecondBonusOne = ""
   $SecondBonusTwo = ""
;   $SecondOvertimeOne = ""
   $SecondOvertimeTwo = ""
;   $SecondCommissionOne = ""
   $SecondCommissionTwo = ""
;   $SecondNetPreTaxProfitLatestYrOne = ""
   $SecondNetPreTaxProfitLatestYrTwo = ""
;   $SecondNetPreTaxProfitPrevYrOne = ""
   $SecondNetPreTaxProfitPrevYrTwo = ""
   ;DoTheBusiness()
EndIf

If $EmpTypeOne = 6 Then
   ;MsgBox(1, "Information", "Applicant 1 is Retired")
   $SalaryOne = ""
;   $SalaryTwo = ""
   $BonusOne = ""
;   $BonusTwo = ""
   $OvertimeOne = ""
;   $OvertimeTwo = ""
   $CommissionOne = ""
;   $CommissionTwo = ""
   $NetPreTaxProfitLatestYrOne = ""
;   $NetPreTaxProfitLatestYrTwo = ""
   $NetPreTaxProfitPrevYrOne = ""
;   $NetPreTaxProfitPrevYrTwo = ""
   $ShareOfNetPreTaxProfitLatestYrOne = ""
   $ShareOfNetPreTaxProfitPrevYrOne = ""
;   $ShareOfNetPreTaxProfitLatestYrTwo = ""
;   $ShareOfNetPreTaxProfitPrevYrTwo = ""
   $SalaryPlusDividendsLatestYrOne = ""
   $SalaryPlusDividendsPrevYrOne = ""
;   $SalaryPlusDividendsLatestYrTwo = ""
;   $SalaryPlusDividendsPrevYrTwo = ""
   $SecondJobOne = 33
;   $SecondJobTwo = 35
   $SecondJobTypeOne = ""
;   $SecondJobTypeTwo = ""
   $SecondJobTenureOne = ""
;   $SecondJobTenureTwo = ""
   $TreatedAsEmployedOne = ""
;   $TreatedAsEmployedTwo = ""
   $YrsIn2ndJobOne = ""
   $MthsIn2ndJobOne = ""
;   $YrsIn2ndJobTwo = ""
;   $MthsIn2ndJobTwo = ""
   $YrsRemOn2ndJobContractOne = ""
   $MthsRemOn2ndJobContractOne = ""
;   $YrsRemOn2ndJobContractTwo = ""
;   $MthsRemOn2ndJobContractTwo = ""
   $SecondSalaryOne = ""
;   $SecondSalaryTwo = ""
   $SecondBonusOne = ""
;   $SecondBonusTwo = ""
   $SecondOvertimeOne = ""
;   $SecondOvertimeTwo = ""
   $SecondCommissionOne = ""
;   $SecondCommissionTwo = ""
   $SecondNetPreTaxProfitLatestYrOne = ""
;   $SecondNetPreTaxProfitLatestYrTwo = ""
   $SecondNetPreTaxProfitPrevYrOne = ""
;   $SecondNetPreTaxProfitPrevYrTwo = ""
;DoTheBusiness()
EndIf

If $EmpTypeTwo = 16 Then
   ;MsgBox(1, "Information", "Applicant 2 is Retired")
;   $SalaryOne = ""
   $SalaryTwo = ""
;   $BonusOne = ""
   $BonusTwo = ""
;   $OvertimeOne = ""
   $OvertimeTwo = ""
;   $CommissionOne = ""
   $CommissionTwo = ""
;   $NetPreTaxProfitLatestYrOne = ""
   $NetPreTaxProfitLatestYrTwo = ""
;   $NetPreTaxProfitPrevYrOne = ""
   $NetPreTaxProfitPrevYrTwo = ""
;   $ShareOfNetPreTaxProfitLatestYrOne = ""
;   $ShareOfNetPreTaxProfitPrevYrOne = ""
   $ShareOfNetPreTaxProfitLatestYrTwo = ""
   $ShareOfNetPreTaxProfitPrevYrTwo = ""
;   $SalaryPlusDividendsLatestYrOne = ""
;   $SalaryPlusDividendsPrevYrOne = ""
   $SalaryPlusDividendsLatestYrTwo = ""
   $SalaryPlusDividendsPrevYrTwo = ""
;   $SecondJobOne = 33
   $SecondJobTwo = 35
;   $SecondJobTypeOne = ""
   $SecondJobTypeTwo = ""
;   $SecondJobTenureOne = ""
   $SecondJobTenureTwo = ""
;   $TreatedAsEmployedOne = ""
   $TreatedAsEmployedTwo = ""
;   $YrsIn2ndJobOne = ""
;   $MthsIn2ndJobOne = ""
   $YrsIn2ndJobTwo = ""
   $MthsIn2ndJobTwo = ""
;   $YrsRemOn2ndJobContractOne = ""
;   $MthsRemOn2ndJobContractOne = ""
   $YrsRemOn2ndJobContractTwo = ""
   $MthsRemOn2ndJobContractTwo = ""
;   $SecondSalaryOne = ""
   $SecondSalaryTwo = ""
   $SecondBonusOne = ""
;   $SecondBonusTwo = ""
   $SecondOvertimeOne = ""
;   $SecondOvertimeTwo = ""
   $SecondCommissionOne = ""
;   $SecondCommissionTwo = ""
   $SecondNetPreTaxProfitLatestYrOne = ""
;   $SecondNetPreTaxProfitLatestYrTwo = ""
   $SecondNetPreTaxProfitPrevYrOne = ""
;   $SecondNetPreTaxProfitPrevYrTwo = ""
;DoTheBusiness()
EndIf

#comments-start
MsgBox(3, "SalaryOne", $SalaryOne)
MsgBox(3, "SalaryTwo", $SalaryTwo)
MsgBox(3, "BonusOne", $BonusOne)
MsgBox(3, "BonusTwo", $BonusTwo)
MsgBox(3, "OvertimeOne", $OvertimeOne)
MsgBox(3, "OvertimeTwo", $OvertimeTwo)
MsgBox(3, "CommissionOne", $CommissionOne)
MsgBox(3, "CommissionTwo", $CommissionTwo)
MsgBox(3, "NetPreTaxProfitLatestYrOne", $NetPreTaxProfitLatestYrOne)
MsgBox(3, "NetPreTaxProfitLatestYrTwo", $NetPreTaxProfitLatestYrTwo)
MsgBox(3, "NetPreTaxProfitPrevYrOne", $NetPreTaxProfitPrevYrOne)
MsgBox(3, "NetPreTaxProfitPrevYrTwo", $NetPreTaxProfitPrevYrTwo)
MsgBox(3, "ShareOfNetPreTaxProfitLatestYrOne", $ShareOfNetPreTaxProfitLatestYrOne)
MsgBox(3, "ShareOfNetPreTaxProfitPrevYrOne", $ShareOfNetPreTaxProfitPrevYrOne)
MsgBox(3, "ShareOfNetPreTaxProfitLatestYrTwo", $ShareOfNetPreTaxProfitLatestYrTwo)
MsgBox(3, "ShareOfNetPreTaxProfitPrevYrTwo", $ShareOfNetPreTaxProfitPrevYrTwo)
MsgBox(3, "SalaryPlusDividendsLatestYrOne", $SalaryPlusDividendsLatestYrOne)
MsgBox(3, "SalaryPlusDividendsPrevYrOne", $SalaryPlusDividendsPrevYrOne)
MsgBox(3, "SalaryPlusDividendsLatestYrTwo", $SalaryPlusDividendsLatestYrTwo)
MsgBox(3, "SalaryPlusDividendsPrevYrTwo", $SalaryPlusDividendsPrevYrTwo)
#comments-end

;Func DoTheBusiness()

$oIE = _IECreate("http://www.nationwide-intermediary.co.uk/calculators/aff_calc")
If Not IsObj($oIE) Then Exit ConsoleWrite("Error in $oIE" & @CRLF)
$oIE = _IEAttach("Affordability Calculator | Nationwide for Intermediaries (NFI)")

_IELoadWait($oIE)

$oClassReturn = $oIE.document.getElementsByClassName("pageContainer page0")
If Not IsObj($oClassReturn) Then Exit ConsoleWrite("Error in $oClassReturn" & @CRLF)

$oTagReturn = $oClassReturn.Item(0).getElementsByTagName("li")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)

For $loop = 1 to 2
$oTagReturn.Item($BuyOrRemo).click() ; Item(1) = "Buy a new property" / Item(2) = "Remortgage" | Running the command twice is require to close the drop-down
Next

$oMtgAmt = _IEGetObjByName($oIE, "bespAppCharsMiscLoanAmountRequested")
_IEAction($oMtgAmt, "focus")
Send("{DEL}")
;_IEFormElementSetValue($oMtgAmt, $MtgAmt)
Send($MtgAmt)

$oMtgTermYrs = _IEGetObjByName($oIE, "bespAppCharsMiscTermRequestedYY")
;_IEFormElementSetValue($oMtgTermYrs, "25")
_IEAction($oMtgTermYrs, "focus")
Send($MtgTermYrs)

$oMtgTermMths = _IEGetObjByName($oIE, "bespAppCharsMiscTermRequestedMM")
;_IEFormElementSetValue($oMtgTermMths, "00")
_IEAction($oMtgTermMths, "focus")
Send($MtgTermMths)

$oTagReturn = $oClassReturn.Item(0).getElementsByTagName("input")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)
$oTagReturn.Item($NumOfApplicants).click() ; Item(3) = One Applicant / Item(4) = Two Applicants

$oTagReturn = $oClassReturn.Item(0).getElementsByTagName("li")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)

For $loop = 1 to 2
$oTagReturn.Item($OwnershipType).click() ; Item(4) = Standard / Item(5) = Equity Share / Item(6) = Right to Buy / Item(7) = Shared Ownership | Running the command twice is require to close the drop-down
Next

$oTagReturn = $oClassReturn.Item(0).getElementsByTagName("input")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)
$oTagReturn.Item($FoundProperty).click() ; Item(5) = Have they found a new home yet 'Yes' / Item(6) = Have they found a new home yet 'No'

$oTagReturn = $oClassReturn.Item(0).getElementsByTagName("li")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)

For $loop = 1 to 2
$oTagReturn.Item($Tenure).click() ; Item(9) = Freehold / Item(10) = Leasehold / Item(11) = Commonhold / Item(12) = Ownership Scotland | Running the command twice is require to close the drop-down
Next

For $loop = 1 to 2
$oTagReturn.Item($PropType).click() ; Item(14) = Detached House / Item(15) = Detached Bungalow / Item(16) = Semi-Detached Bungalow / Item(17) = Terraced Bungalow / Item(18) = Semi-Detached House / Item(19) = Terraced House / Item(20) = Purpose built flat/maisonette / Item(21) = Converted flat/maisonette | Running the command twice is require to close the drop-down
Next

$oPP = _IEGetObjByName($oIE, "bespAppCharsMiscExpectedPurchasePriceMSO")
_IEAction($oPP, "focus")
Send("{DEL}")
;_IEFormElementSetValue($oPP, "200000")
Send($PP)

$oDOBAppOne = _IEGetObjByName($oIE, "bespMainAppDateOfBirth")
;_IEFormElementSetValue($oDOBAppOne, "01011990")
_IEAction($oDOBAppOne, "focus")
Send($DOB1)

$oDOBAppTwo = _IEGetObjByName($oIE, "bespJointAppDateOfBirth")
;_IEFormElementSetValue($oDOBAppTwo, "01011990")
_IEAction($oDOBAppTwo, "focus")
Send($DOB2)

$oClassReturn = $oIE.document.getElementsByClassName("pageContainer page1")
If Not IsObj($oClassReturn) Then Exit ConsoleWrite("Error in $oClassReturn" & @CRLF)

$oTagReturn = $oClassReturn.Item(0).getElementsByTagName("li")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)

For $loop = 1 to 2
$oTagReturn.Item($Gender1).click() ; Item(1) = Male / Item(2) = Female | Applicant one
Next

For $loop = 1 to 2
$oTagReturn.Item($Gender2).click() ; Item(4) = Male / Item(5) = Female | Applicant two
Next

$oTagReturn = $oClassReturn.Item(0).getElementsByTagName("input")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)
$oTagReturn.Item($Dependents1).click() ; Item(2) = Has dependents / Item(3) = No dependents | Applicant one
$oTagReturn.Item($Dependents2).click() ; Item(4) = Has dependents / Item(5) = No dependents | Applicant one

$oDependentsZeroToFiveAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMDependantsAgeRange1")
_IEAction($oDependentsZeroToFiveAppOne, "focus")
Send("{DEL}")
;_IEFormElementSetValue($oDependentsZeroToFiveAppOne, "1")
Send($Deps10To5)

$oDependentsSixToElevenAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMDependantsAgeRange2")
_IEAction($oDependentsSixToElevenAppOne, "focus")
Send("{DEL}")
;_IEFormElementSetValue($oDependentsSixToElevenAppOne, "2")
Send($Deps16To11)

$oDependentsTwelveToSeventeenAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMDependantsAgeRange3")
_IEAction($oDependentsTwelveToSeventeenAppOne, "focus")
Send("{DEL}")
;_IEFormElementSetValue($oDependentsTwelveToSeventeenAppOne, "3")
Send($Deps112To17)

$oDependentsEighteenPlusAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMDependantsAgeRange4")
_IEAction($oDependentsEighteenPlusAppOne, "focus")
Send("{DEL}")
;_IEFormElementSetValue($oDependentsEighteenPlusAppOne, "4")
Send($Deps118Plus)

$oDependentsZeroToFiveAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrJDependantsAgeRange1")
_IEAction($oDependentsZeroToFiveAppTwo, "focus")
Send("{DEL}")
;_IEFormElementSetValue($oDependentsZeroToFiveAppTwo, "1")
Send($Deps20To5)

$oDependentsSixToElevenAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrJDependantsAgeRange2")
_IEAction($oDependentsSixToElevenAppTwo, "focus")
Send("{DEL}")
;_IEFormElementSetValue($oDependentsSixToElevenAppTwo, "2")
Send($Deps26To11)

$oDependentsTwelveToSeventeenAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrJDependantsAgeRange3")
_IEAction($oDependentsTwelveToSeventeenAppTwo, "focus")
Send("{DEL}")
;_IEFormElementSetValue($oDependentsTwelveToSeventeenAppTwo, "3")
Send($Deps212To17)

$oDependentsEighteenPlusAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrJDependantsAgeRange4")
_IEAction($oDependentsEighteenPlusAppTwo, "focus")
Send("{DEL}")
;_IEFormElementSetValue($oDependentsEighteenPlusAppTwo, "4")
Send($Deps218Plus)

$oTagReturn.Item($Retired1).click() ; Item(14) = Is retired / Item(15) = Not retired | Applicant one
$oTagReturn.Item($Retired2).click() ; Item(16) = Is retired / Item(17) = Not retired | Applicant two

$oRetAgeAppOne = _IEGetObjByName($oIE, "bespMainAppMExpectedRetirementAge")
;_IEFormElementSetValue($oRetAgeAppOne, "65")
_IEAction($oRetAgeAppOne, "focus")
Send($RetAge1)

$oRetAgeAppTwo = _IEGetObjByName($oIE, "bespJointAppJExpectedRetirementAge")
;_IEFormElementSetValue($oRetAgeAppTwo, "65")
_IEAction($oRetAgeAppTwo, "focus")
Send($RetAge2)

$oTagReturn = $oIE.document.getElementsByTagName("button")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)
$oTagReturn.Item(1).Click()

$oClassReturn = $oIE.document.getElementsByClassName("pageContainer page3")
If Not IsObj($oClassReturn) Then Exit ConsoleWrite("Error in $oClassReturn" & @CRLF)

$oTagReturn = $oClassReturn.Item(0).getElementsByTagName("li")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)

For $loop = 1 to 2
$oTagReturn.Item($EmpTypeOne).click() ; Item(1) = Employed / Item(2) = Self-employed (partner) / Item(3) = Self-employed (sole-trader) / Item(4) = Director <=20% / Item(5) = Director =>20% / Item(6) = Retired / Item(7) = Homemaker / Item(8) = Student / Item(9) = Unemployed | Applicant one
Next

For $loop = 1 to 2
$oTagReturn.Item($EmpTypeTwo).click() ; Item(11) = Employed / Item(12) = Self-employed (partner) / Item(13) = Self-employed (sole-trader) / Item(14) = Director <=20% / Item(15) = Director =>20% / Item(16) = Retired / Item(17) = Homemaker / Item(18) = Student / Item(19) = Unemployed | Applicant two
Next

For $loop = 1 to 2
$oTagReturn.Item($EmpTenureOne).click() ; Item(21) = Permanent / Item(22) = Fixed term contract / Item(23) = Sub-contractor fixed term / Item(24) = Sub-contractor open ended / Item(25) = Temporary | Applicant one
Next

For $loop = 1 to 2
$oTagReturn.Item($EmpTenureTwo).click() ; Item(27) = Permanent / Item(28) = Fixed term contract / Item(29) = Sub-contractor fixed term / Item(30) = Sub-contractor open ended / Item(31) = Temporary | Applicant two
Next

$oTagReturn = $oClassReturn.Item(0).getElementsByTagName("input")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)

$oTagReturn.Item($TreatedAsEmployedOne).click() ; Item(0) = Are they treated as employed for tax purposes 'Yes' / Item(1) = 'No' | Applicant one
$oTagReturn.Item($TreatedAsEmployedTwo).click() ; Item(2) = Are they treated as employed for tax purposes 'Yes' / Item(3) = 'No' | Applicant two

$oTimeInJobAppOneYY = _IEGetObjByName($oIE, "bespMainAppMTimeWithCurrentEmployerYY")
;_IEFormElementSetValue($oTimeInJobAppOneYY, "YY")
_IEAction($oTimeInJobAppOneYY, "focus")
Send($YrsInJobOne)

$oTimeInJobAppOneMM = _IEGetObjByName($oIE, "bespMainAppMTimeWithCurrentEmployerMM")
;_IEFormElementSetValue($oTimeInJobAppOneMM, "MM")
_IEAction($oTimeInJobAppOneMM, "focus")
Send($MthsInJobOne)

$oTimeInJobAppTwoYY = _IEGetObjByName($oIE, "bespJointAppJTimeWithCurrentEmployerYY")
;_IEFormElementSetValue($oTimeInJobAppTwoYY, "YY")
_IEAction($oTimeInJobAppTwoYY, "focus")
Send($YrsInJobTwo)

$oTimeInJobAppTwoMM = _IEGetObjByName($oIE, "bespJointAppJTimeWithCurrentEmployerMM")
;_IEFormElementSetValue($oTimeInJobAppTwoMM, "MM")
_IEAction($oTimeInJobAppTwoMM, "focus")
Send($MthsInJobTwo)

$oRemainingTermOnContractAppOneYY = _IEGetObjByName($oIE, "bespMainAppMRemainingTermOnContractYY")
;_IEFormElementSetValue($oRemainingTermOnContractAppOneYY, "YY")
_IEAction($oRemainingTermOnContractAppOneYY, "focus")
Send($YrsRemOnContractOne)

$oRemainingTermOnContractAppOneMM = _IEGetObjByName($oIE, "bespMainAppMRemainingTermOnContractMM")
;_IEFormElementSetValue($oRemainingTermOnContractAppOneMM, "MM")
_IEAction($oRemainingTermOnContractAppOneMM, "focus")
Send($MthsRemOnContractOne)

$oRemainingTermOnContractAppTwoYY = _IEGetObjByName($oIE, "bespJointAppJRemainingTermOnContractYY")
;_IEFormElementSetValue($oRemainingTermOnContractAppTwoYY, "YY")
_IEAction($oRemainingTermOnContractAppTwoYY, "focus")
Send($YrsRemOnContractTwo)

$oRemainingTermOnContractAppTwoMM = _IEGetObjByName($oIE, "bespJointAppJRemainingTermOnContractMM")
;_IEFormElementSetValue($oRemainingTermOnContractAppTwoMM, "MM")
_IEAction($oRemainingTermOnContractAppTwoMM, "focus")
Send($MthsRemOnContractTwo)

$oAnnualSalaryAppOne = _IEGetObjByName($oIE, "bespMainAppMGrossAnnualIncome")
;_IEFormElementSetValue($oAnnualSalaryAppOne, "100000")
_IEAction($oAnnualSalaryAppOne, "focus")
Send("{DEL}")
Send($SalaryOne)

$oAnnualBonusAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMainIncomeMBonus")
;_IEFormElementSetValue($oAnnualBonusAppOne, "100000")
_IEAction($oAnnualBonusAppOne, "focus")
Send("{DEL}")
Send($SalaryTwo)

$oAnnualOvertimeAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMainIncomeMOvertime")
;_IEFormElementSetValue($oAnnualOvertimeAppOne, "100000")
_IEAction($oAnnualOvertimeAppOne, "focus")
Send("{DEL}")
Send($BonusOne)

$oAnnualCommissionAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMainIncomeMCommission")
;_IEFormElementSetValue($oAnnualCommissionAppOne, "100000")
_IEAction($oAnnualCommissionAppOne, "focus")
Send("{DEL}")
Send($BonusTwo)

$oAnnualSalaryAppTwo = _IEGetObjByName($oIE, "bespJointAppJGrossAnnualIncome")
;_IEFormElementSetValue($oAnnualSalaryAppTwo, "100000")
_IEAction($oAnnualSalaryAppTwo, "focus")
Send("{DEL}")
Send($OvertimeOne)

$oAnnualBonusAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrMainIncomeJBonus")
;_IEFormElementSetValue($oAnnualBonusAppTwo, "100000")
_IEAction($oAnnualBonusAppTwo, "focus")
Send("{DEL}")
Send($OvertimeTwo)

$oAnnualOvertimeAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrMainIncomeJOvertime")
;_IEFormElementSetValue($oAnnualOvertimeAppTwo, "100000")
_IEAction($oAnnualOvertimeAppTwo, "focus")
Send("{DEL}")
Send($CommissionOne)

$oAnnualCommissionAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrMainIncomeJCommission")
;_IEFormElementSetValue($oAnnualCommissionAppTwo, "100000")
_IEAction($oAnnualCommissionAppTwo, "focus")
Send("{DEL}")
Send($CommissionTwo)

$oAnnualNetProfitBeforeTaxLatestYearAppOne = _IEGetObjByName($oIE, "bespMainAppMNetProfitBeforeTax")
;_IEFormElementSetValue($oAnnualNetProfitBeforeTaxLatestYearAppOne, "100000")
_IEAction($oAnnualNetProfitBeforeTaxLatestYearAppOne, "focus")
Send("{DEL}")
Send($NetPreTaxProfitLatestYrOne)

$oAnnualNetProfitBeforeTaxPreviousYearAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMainIncomeMPreviousPeriodNetProfitBeforeTax")
;_IEFormElementSetValue($oAnnualNetProfitBeforeTaxPreviousYearAppOne, "100000")
_IEAction($oAnnualNetProfitBeforeTaxPreviousYearAppOne, "focus")
Send("{DEL}")
Send($NetPreTaxProfitLatestYrTwo)

$oAnnualNetProfitBeforeTaxLatestYearAppOne = _IEGetObjByName($oIE, "bespJointAppJNetProfitBeforeTax")
;_IEFormElementSetValue($oAnnualNetProfitBeforeTaxLatestYearAppOne, "100000")
_IEAction($oAnnualNetProfitBeforeTaxLatestYearAppOne, "focus")
Send("{DEL}")
Send($NetPreTaxProfitPrevYrOne)

$oAnnualNetProfitBeforeTaxPreviousYearAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrMainIncomeJPreviousPeriodNetProfitBeforeTax")
;_IEFormElementSetValue($oAnnualNetProfitBeforeTaxPreviousYearAppTwo, "100000")
_IEAction($oAnnualNetProfitBeforeTaxPreviousYearAppTwo, "focus")
Send("{DEL}")
Send($NetPreTaxProfitPrevYrTwo)

$oShareOfAnnualNetProfitBeforeTaxLatestYearAppOne = _IEGetObjByName($oIE, "bespMainAppMShareOfNetProfitBeforeTax")
;_IEFormElementSetValue($oShareOfAnnualNetProfitBeforeTaxLatestYearAppOne, "100000")
_IEAction($oShareOfAnnualNetProfitBeforeTaxLatestYearAppOne, "focus")
Send("{DEL}")
Send($ShareOfNetPreTaxProfitLatestYrOne)

$oShareOfAnnualNetProfitBeforeTaxPreviousYearAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMainIncomeMPreviousPeriodShareofNetProfitBeforeTax")
;_IEFormElementSetValue($oShareOfAnnualNetProfitBeforeTaxPreviousYearAppOne, "100000")
_IEAction($oShareOfAnnualNetProfitBeforeTaxPreviousYearAppOne, "focus")
Send("{DEL}")
Send($ShareOfNetPreTaxProfitPrevYrOne)

$oShareOfAnnualNetProfitBeforeTaxLatestYearAppTwo = _IEGetObjByName($oIE, "bespJointAppJShareOfNetProfitBeforeTax")
;_IEFormElementSetValue($oShareOfAnnualNetProfitBeforeTaxLatestYearAppTwo, "100000")
_IEAction($oShareOfAnnualNetProfitBeforeTaxLatestYearAppTwo, "focus")
Send("{DEL}")
Send($ShareOfNetPreTaxProfitLatestYrTwo)

$oShareOfAnnualNetProfitBeforeTaxPreviousYearAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrMainIncomeJPreviousPeriodShareofNetProfitBeforeTax")
;_IEFormElementSetValue($oShareOfAnnualNetProfitBeforeTaxPreviousYearAppTwo, "100000")
_IEAction($oShareOfAnnualNetProfitBeforeTaxPreviousYearAppTwo, "focus")
Send("{DEL}")
Send($ShareOfNetPreTaxProfitPrevYrTwo)

$oSalaryPlusDividendsLatestYearAppOne = _IEGetObjByName($oIE, "bespMainAppMSalaryandDividends")
;_IEFormElementSetValue($oSalaryPlusDividendsLatestYearAppOne, "100000")
_IEAction($oSalaryPlusDividendsLatestYearAppOne, "focus")
Send("{DEL}")
Send($SalaryPlusDividendsLatestYrOne)

$oSalaryPlusDividendsPrevYearAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMainIncomeMPreviousPeriodSalaryAndDividends")
;_IEFormElementSetValue($oSalaryPlusDividendsPrevYearAppOne, "100000")
_IEAction($oSalaryPlusDividendsPrevYearAppOne, "focus")
Send("{DEL}")
Send($SalaryPlusDividendsPrevYrOne)

$oSalaryPlusDividendsLatestYearAppTwo = _IEGetObjByName($oIE, "bespJointAppJSalaryandDividends")
;_IEFormElementSetValue($oSalaryPlusDividendsLatestYearAppTwo, "100000")
_IEAction($oSalaryPlusDividendsLatestYearAppTwo, "focus")
Send("{DEL}")
Send($SalaryPlusDividendsPrevYrTwo)

$oSalaryPlusDividendsPrevYearAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrMainIncomeJPreviousPeriodSalaryAndDividends")
;_IEFormElementSetValue($oSalaryPlusDividendsPrevYearAppTwo, "100000")
_IEAction($oSalaryPlusDividendsPrevYearAppTwo, "focus")
Send("{DEL}")
Send($SalaryPlusDividendsPrevYrTwo)

$oTagReturn = $oClassReturn.Item(0).getElementsByTagName("input")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)
$oTagReturn.Item($SecondJobOne).click() ; Item(32) = Does applicant one have a second job 'Yes' / Item(33) = 'No' | Applicant one
$oTagReturn.Item($SecondJobTwo).click() ; Item(34) = Does applicant one have a second job 'Yes' / Item(35) = 'No' | Applicant two
Exit

There is also a screenshot attached of the results after running the script with EmpTypeOne set to Employed and EmpTypeTwo set to SEP (which is Self-employed (partner))

Data.txt

Capture.PNG

Edited by Dent
Make URL a link instead of plain text
Link to comment
Share on other sites

Hello Dent,

Let's change this "send" functions, ok? So your script will be more reliable. Shall we? :)

Before that, may i give you some suggestions?

  • First test all the form actions to make sure you can deal with every input.
  • Split the form scripting in 4 parts (Mortage / Income / Outgoings / Result).
  • Before you go for example: from "Mortage" to "Income" make sure that the error (The highlighted row(s) contain(s) an error, please check the information and re-enter.) is not present.
  • Make a documentation (like you are already doing with the comments) os every input/element you need to work with.
  • Only grab the element/inputs that you need to work with. As each of the client(s) data is unique so some of the element will be need some will not. In the array make a identification of wich element is needed and wich is not so you will only grab the ones that you need (you can do that with: If Then Endif).
  • For last debug. Use a Msgbox and see all the data that you are working with (the array values / the element name etc). Make sure that you inputting the right data in the correct element.

Let's get back to fun part.

#include <IE.au3>

Local $oIE = _IECreate("http://www.nationwide-intermediary.co.uk/calculators/aff_calc")
If Not IsObj($oIE) Then Exit ConsoleWrite("Error in $oIE" & @CRLF)

Local $oClassReturn = $oIE.document.getElementsByClassName("pageContainer page0")
If Not IsObj($oClassReturn) Then Exit ConsoleWrite("Error in $oClassReturn" & @CRLF)

Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("li")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)

$oTagReturn.Item(1).click() ; Item(1) = "Buy a new property" / Item(2) = "Remortgage" | Running the command twice is require to close the drop-down
$oTagReturn.Item(1).click()

Local $oMtgAmt = _IEGetObjByName($oIE, "bespAppCharsMiscLoanAmountRequested")
$oMtgAmt.Value = Null
_IEDocInsertText($oMtgAmt, "100000")

Local $oMtgTermYrs = _IEGetObjByName($oIE, "bespAppCharsMiscTermRequestedYY")
_IEDocInsertText($oMtgTermYrs, "25")

Local $oMtgTermMths = _IEGetObjByName($oIE, "bespAppCharsMiscTermRequestedMM")
_IEDocInsertText($oMtgTermMths, "00")

Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("input")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)
$oTagReturn.Item(4).click() ; Item(3) = One Applicant / Item(4) = Two Applicants

Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("li")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)

$oTagReturn.Item(4).click() ; Item(4) = Standard / Item(5) = Equity Share / Item(6) = Right to Buy / Item(7) = Shared Ownership | Running the command twice is require to close the drop-down
$oTagReturn.Item(4).click()

Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("input")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)
$oTagReturn.Item(5).click() ; Item(5) = Have they found a new home yet 'Yes' / Item(6) = Have they found a new home yet 'No'

Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("li")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)

$oTagReturn.Item(9).click() ; Item(9) = Freehold / Item(10) = Leasehold / Item(11) = Commonhold / Item(12) = Ownership Scotland | Running the command twice is require to close the drop-down
$oTagReturn.Item(9).click()

$oTagReturn.Item(14).click() ; Item(14) = Detached House / Item(15) = Detached Bungalow / Item(16) = Semi-Detached Bungalow / Item(17) = Terraced Bungalow / Item(18) = Semi-Detached House / Item(19) = Terraced House / Item(20) = Purpose built flat/maisonette / Item(21) = Converted flat/maisonette | Running the command twice is require to close the drop-down
$oTagReturn.Item(14).click()

Local $oPP = _IEGetObjByName($oIE, "bespAppCharsMiscExpectedPurchasePriceMSO")
$oPP.Value = Null
_IEDocInsertText($oPP, "200000")

Local $oDOBAppOne = _IEGetObjByName($oIE, "bespMainAppDateOfBirth")
_IEDocInsertText($oDOBAppOne, "01/01/1990")

Local $oDOBAppOne = _IEGetObjByName($oIE, "bespJointAppDateOfBirth")
_IEDocInsertText($oDOBAppOne, "01/01/1990")

Local $oClassReturn = $oIE.document.getElementsByClassName("pageContainer page1")
If Not IsObj($oClassReturn) Then Exit ConsoleWrite("Error in $oClassReturn" & @CRLF)

Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("li")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)

$oTagReturn.Item(1).click() ; Item(1) = Male / Item(2) = Female | Applicant one
$oTagReturn.Item(1).click()

$oTagReturn.Item(5).click() ; Item(4) = Male / Item(5) = Female | Applicant two
$oTagReturn.Item(5).click()

Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("input")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)
$oTagReturn.Item(2).click() ; Item(2) = Has dependents / Item(3) = No dependents | Applicant one
$oTagReturn.Item(4).click() ; Item(4) = Has dependents / Item(5) = No dependents | Applicant one

Sleep(1000)

Local $oDependentsZeroToFiveAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMDependantsAgeRange1")
$oDependentsZeroToFiveAppOne.Value = Null
_IEDocInsertText($oDependentsZeroToFiveAppOne, "1")

Local $oDependentsSixToElevenAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMDependantsAgeRange2")
$oDependentsSixToElevenAppOne.Value = Null
_IEDocInsertText($oDependentsSixToElevenAppOne, "2")

Local $oDependentsTwelveToSeventeenAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMDependantsAgeRange3")
$oDependentsTwelveToSeventeenAppOne.Value = Null
_IEDocInsertText($oDependentsTwelveToSeventeenAppOne, "3")

Local $oDependentsEighteenPlusAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMDependantsAgeRange4")
$oDependentsEighteenPlusAppOne.Value = Null
_IEDocInsertText($oDependentsEighteenPlusAppOne, "4")

Local $oDependentsZeroToFiveAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrJDependantsAgeRange1")
$oDependentsZeroToFiveAppTwo.Value = Null
_IEDocInsertText($oDependentsZeroToFiveAppTwo, "1")

Local $oDependentsSixToElevenAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrJDependantsAgeRange2")
$oDependentsSixToElevenAppTwo.Value = Null
_IEDocInsertText($oDependentsSixToElevenAppTwo, "2")

Local $oDependentsTwelveToSeventeenAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrJDependantsAgeRange3")
$oDependentsTwelveToSeventeenAppTwo.Value = Null
_IEDocInsertText($oDependentsTwelveToSeventeenAppTwo, "3")

Local $oDependentsEighteenPlusAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrJDependantsAgeRange4")
$oDependentsEighteenPlusAppTwo.Value = Null
_IEDocInsertText($oDependentsEighteenPlusAppTwo, "4")

$oTagReturn.Item(15).click() ; Item(14) = Is retired / Item(15) = Not retired | Applicant one
$oTagReturn.Item(17).click() ; Item(16) = Is retired / Item(17) = Not retired | Applicant one

Local $oRetAgeAppOne = _IEGetObjByName($oIE, "bespMainAppMExpectedRetirementAge")
$oRetAgeAppOne.Value = Null
_IEDocInsertText($oRetAgeAppOne, "65")

Local $oRetAgeAppTwo = _IEGetObjByName($oIE, "bespJointAppJExpectedRetirementAge")
$oRetAgeAppTwo.Value = Null
_IEDocInsertText($oRetAgeAppTwo, "65")

Local $oTagReturn = $oIE.document.getElementsByTagName("button")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)
$oTagReturn.Item(1).Click()

_IELoadWait($oIE, 3000) ; just to make sure before we go to the Income part.

Local $oClassReturn = $oIE.document.getElementsByClassName("pageContainer page3")
If Not IsObj($oClassReturn) Then Exit ConsoleWrite("Error in $oClassReturn" & @CRLF)

Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("li")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)

$oTagReturn.Item(2).click() ; Item(1) = Employed / Item(2) = Self-employed (partner) / Item(3) = Self-employed (partner) / Item(4) = Director <=20% / Item(5) = Director =>20% / Item(6) = Retired / Item(7) = Homemaker / Item(8) = Student / Item(9) = Unemployed | Applicant one
$oTagReturn.Item(2).click()

$oTagReturn.Item(11).click() ; Item(11) = Employed / Item(12) = Self-employed (partner) / Item(13) = Self-employed (partner) / Item(14) = Director <=20% / Item(15) = Director =>20% / Item(16) = Retired / Item(17) = Homemaker / Item(18) = Student / Item(19) = Unemployed | Applicant two
$oTagReturn.Item(11).click()

;****************************** in this simulation we will not use that
;$oTagReturn.Item(21).click() ; Item(21) = Permanent / Item(22) = Fixed term contract / Item(23) Sub-contractor fixed term / Item(24) Sub-contractor open ended / Item(25) Temporary | Applicant one
;$oTagReturn.Item(21).click()
;******************************************************

$oTagReturn.Item(27).click() ; Item(27) = Permanent / Item(28) = Fixed term contract / Item(29) Sub-contractor fixed term / Item(30) Sub-contractor open ended / Item(31) Temporary | Applicant two
$oTagReturn.Item(27).click()

Local $oTimeInJobAppOneYY = _IEGetObjByName($oIE, "bespMainAppMTimeWithCurrentEmployerYY")
_IEDocInsertText($oTimeInJobAppOneYY, "10")

Local $oTimeInJobAppOneMM = _IEGetObjByName($oIE, "bespMainAppMTimeWithCurrentEmployerMM")
_IEDocInsertText($oTimeInJobAppOneMM, "10")

Local $oTimeInJobAppTwoYY = _IEGetObjByName($oIE, "bespJointAppJTimeWithCurrentEmployerYY")
_IEDocInsertText($oTimeInJobAppTwoYY, "08")

Local $oTimeInJobAppTwoMM = _IEGetObjByName($oIE, "bespJointAppJTimeWithCurrentEmployerMM")
_IEDocInsertText($oTimeInJobAppTwoMM, "08")

;****************************** in this simulation we will not use that
;~ Local $oAnnualSalaryAppOne = _IEGetObjByName($oIE, "bespJointAppJGrossAnnualIncome")
;~ $oAnnualSalaryAppOne.Value = Null
;~ _IEDocInsertText($oAnnualSalaryAppOne, "100000")
;******************************************************

Local $oAnnualSalaryAppTwo = _IEGetObjByName($oIE, "bespJointAppJGrossAnnualIncome")
$oAnnualSalaryAppTwo.Value = Null
_IEDocInsertText($oAnnualSalaryAppTwo, "100000")

;****************************** in this simulation we will not use that
;~ Local $oAnnualBonusAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMainIncomeMBonus")
;~ $oAnnualBonusAppOne.Value = Null
;~ _IEDocInsertText($oAnnualBonusAppOne, "100000")
;******************************************************

Local $oAnnualBonusAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrMainIncomeJBonus")
$oAnnualBonusAppTwo.Value = Null
_IEDocInsertText($oAnnualBonusAppTwo, "100000")

;****************************** in this simulation we will not use that
;~ Local $oAnnualOvertimeAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMainIncomeMOvertime")
;~ $oAnnualOvertimeAppOne.Value = Null
;~ _IEDocInsertText($oAnnualOvertimeAppOne, "100000")
;******************************************************

Local $oAnnualOvertimeAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrMainIncomeJOvertime")
$oAnnualOvertimeAppTwo.Value = Null
_IEDocInsertText($oAnnualOvertimeAppTwo, "100000")

;****************************** in this simulation we will not use that
;~ Local $oAnnualCommissionAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMainIncomeMCommission")
;~ $oAnnualCommissionAppOne.Value = Null
;~ _IEDocInsertText($oAnnualCommissionAppOne, "100000")
;******************************************************

Local $oAnnualCommissionAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrMainIncomeJCommission")
$oAnnualCommissionAppTwo.Value = Null
_IEDocInsertText($oAnnualCommissionAppTwo, "100000")

Local $oProfitBeforeTax = _IEGetObjByName($oIE, "bespMainAppMShareOfNetProfitBeforeTax")
$oProfitBeforeTax.Value = Null
_IEDocInsertText($oProfitBeforeTax, "100000")

Local $oProfitBeforeTaxPreviousPeriod = _IEGetObjByName($oIE, "bespMainAppMmrMainIncomeMPreviousPeriodShareofNetProfitBeforeTax")
$oProfitBeforeTaxPreviousPeriod.Value = Null
_IEDocInsertText($oProfitBeforeTaxPreviousPeriod, "100000")

Local $oClassReturn = $oIE.document.getElementsByClassName("row")
If Not IsObj($oClassReturn) Then Exit ConsoleWrite("Error in $oClassReturn" & @CRLF)

Local $oTagReturn = $oClassReturn.Item(38).getElementsByTagName("input")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)
$oTagReturn.Item(1).click() ; Does your customer have any other income? | Applicant one | Item(0) = 'Yes' / Item(1) = 'No'
$oTagReturn.Item(3).click() ; Does your customer have any other income? | Applicant two | Item(2) = 'Yes' / Item(3) = 'No'

Local $oTagReturn = $oClassReturn.Item(55).getElementsByTagName("input")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)
$oTagReturn.Item(1).click() ; Does your customer have any other income? | Applicant one | Item(0) = 'Yes' / Item(1) = 'No'
$oTagReturn.Item(3).click() ; Does your customer have any other income? | Applicant two | Item(2) = 'Yes' / Item(3) = 'No'

Local $oTagReturn = $oIE.document.getElementsByTagName("button")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)
$oTagReturn.Item(3).Click()

Exit

You will notice of some ".value = Null", this is to erase the data before we input a new one. Some of the input will need to be erase, some not, this is because of how the java is validating the data, for example the inputs that already has a number like "0". The date inputs need to have the "/", so "01011990" is not the same as "01/01/1990".

So with this aproach we dont need to windows to have focus and it will lead you to the "Outgoings" part.

To resolve the problem that you mentioned with the "second part" all you need is to debug your code, check the array values and they respective element, as i said make a validation of wich data will be needed and where it will be needed.

Link to comment
Share on other sites

51 minutes ago, Dent said:

Are you in the UK?

Almost. Only a continent away (Brazil). If I visit the UK I will remember you that you owe me a beer! :D

I was kind in a hurry when i posted #2, so excuse my grammar or any of the concordance mistake.

I forgot to suggest that you should put on each object a validation/check as "IsObject" or "Not @Error" (if its a function) and build a "Com Error Handler". Let me know if the example works.

Link to comment
Share on other sites

Yes, it works very well.

I was using If.. Then.. ElseIf.. EndIf etc for filtering out the required values. However I've noticed that using your implementation above I can just read all the data and write it all to the form and the form will only take the required fields and ignore the rest. So although this isn't ideal because it slows the script down slightly and is sending data that isn't needed, it works!

It's much faster this way and more robust as it doesn't matter which window has focus.

You're awesome. :thumbsup:

Link to comment
Share on other sites

  • 2 weeks later...

Hi, me again :)

I've been away on holiday and had lots of work to catch up with so only just back to working on this again.

Hopefully this will be the last help I need on this particular project (although probably not ;))

On the 'Outgoings' section there is this section (see image) and I can't seem to click 'Yes' for either applicant.

I've used a For loop to cycle through a long range of numbers and watched the page whilst it runs but nothing gets selected :(

 

Capture.JPG

Link to comment
Share on other sites

Hello Dent,

You already have all the tools that you need to do that and you have done similar stuff in your script. :)

Try to get the input ID (if this is similar to the others, it will oly have the name property). Study and understand the "_IEGetObjByName" function, after that ask youself what do you want to do with that element? Select (similar to click)? Can you click with _IEAction($OBJ, "click") ? Please pay special attention to the third parameter of the "_IEGetObjByName" function, here you can grab the correct input element if the name occurs more than one time.

I know that you will be able to do this task. :) Let me know when you accomplish.

Link to comment
Share on other sites

MichaelHB,

You were right, I think I was too tired to see it. I opened it this morning and saw the problem and solved it immediately :)

Whilst I'm writing I have another question. If I wanted to run this script twice, simultaneously, then it seems to me that the script could get confused as to which instance of IE to attach to as both would visit the same site with the same page title. I will test the following, but I'm thinking; would it be possible as soon as IE visits the page to write a new page title with a random number in it and have the script attach to this one so any new instance of the script would just attach to the IE with the random <title> number that it had written to it?

Link to comment
Share on other sites

Glad to know that you solved the radio click. :)

What i would do in your case:

  • 2 Scripts
  1. One with a GUI where you can iput the all the data (like the applicants info) or choose from where it will grab you data source.
  2. And the other this script that you already have, to fill the website form. (you can run this 2x and pass different data look in the helpfile for  the term Running Scripts)

You dont need to make a random number to input to the url as the function IECreate will return the obj that has been created and will only try to attach if you use this parameter. So no problem working with 2 IE instances in the same website, the objects will not be the same.

Link to comment
Share on other sites

Hi MichaelHB,

I'll go search the helpfile now for Running Scripts.

You say that each object created to handle an instance of IE is unique which I understand e.g. $IE1 = _IECreate ... $IE2 = _IECreate and you can choose which handle to interact with.

This is ok if you know the maximum number of IE instances you will create, but what if the script was being called with unique data multiple times? Can you create an object handler with a random name? So $($randomnumber) = _IECreate... with $randomnumber being a random number?

Ok so I've read Running Scripts, a solution I see is passing a random number to the script via the commandline, this would require generating the random number outside of the script, which can be done easily I suppose. I just thought it might be nicer to keep it all contained within the script.

Edited by Dent
Update
Link to comment
Share on other sites

It will be easier if I show you with an example. Compile the runIE example and then run the main example (this one dont need to be compiled). Put them both in the same folder.

  • runIE (need to be compiled)
#include <IE.au3>

If $CmdLine[0] > 1 Then
    Local $oIE = _IECreate($CmdLine[1])
    MsgBox(0, "", "I will now navigate to: " & $CmdLine[2])
    _IENavigate($oIE, $CmdLine[2])
Else
    MsgBox(0, "Error", "No parameters found!")
EndIf

Exit
  • main
ShellExecute(@ScriptDir & "\runIE.exe", 'http://www.autoitscript.com http://www.autoitscript.com/forum/index.php?')
Sleep(3000)
ShellExecute(@ScriptDir & "\runIE.exe", 'http://www.google.com http://www.yahoo.com')

; or with Run()

;~ Run(@ScriptDir & '\runIE.exe http://www.autoitscript.com http://www.autoitscript.com/forum/index.php?')
;~ Sleep(3000)
;~ Run(@ScriptDir & '\runIE.exe http://www.google.com http://www.yahoo.com')

Despite the variable name is the same, the oIE object is unique in each instance of the script. This also shows you how to pass parameters to your own autoit scripts. So no need to know how many ie instance you will need, or if there is one already.

Link to comment
Share on other sites

Thanks for this MichealHB.

Knowing that each instance will somehow be uniquely identifiable is great news. I became aware that because of the long running time of the script there is a chance another instance could be called before the currently running one is completed but now it seems that won't cause a problem.

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

×
×
  • Create New...