Jump to content

Recommended Posts

Posted (edited)

OK, Have a windows application... Called rate calculator...

It's running happily along, getting rates fed to it by me, via autoit3 & ExcelCOM_UDF... life is good

Suddenly, there is an error... a popup box opens and says so.

My code slowly peters to a halt... the buttons and combo boxes are acting all wonky and it is stuck....

not good

So, what I need to do is ... trigger an event???

If a message box appears, go handle it?

(The message box has the same title as the windows application... and the text within varies. Here's an example, showing auto info on it)

Edited by everseeker

Everseeker

Posted

Adlib? that work for ya?

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
Posted

Here's a quick solution wich uses winhandles:

$handle = WinGethandle("Rate Calculator")
While 1
    If WinGetHandle("")<>$handle And WinGetTitle("")="Rate Calculator" Then
        MsgBox(0,"Aha!","Error box detected!")
    EndIf
    Sleep(10)
WEnd

Ummm... So, I am thinking that repeating the If/Then around my program would allow detection.... could work.

Is there a "Goto" or a way to branch to a cert. part of code conditionally? (On Error Goto.... but not an error Function handler...)

Everseeker

Posted (edited)

Is there a "Goto" or a way to branch to a cert. part of code conditionally? (On Error Goto.... but not an error Function handler...)

I have no idea what you're talking about... Edited by monoceres

Broken link? PM me and I'll send you the file!

Posted (edited)

Ummm... So, I am thinking that repeating the If/Then around my program would allow detection.... could work.

Is there a "Goto" or a way to branch to a cert. part of code conditionally? (On Error Goto.... but not an error Function handler...)

No. Functions are the only way.

Huh?

Like this:

AdlibEnable("Check4Error")

;Code here

Func Check4Error()
$handle = WinGethandle("Rate Calculator")
    If WinGetHandle("")<>$handle And WinGetTitle("")="Rate Calculator" Then
        MsgBox(0,"Aha!","Error box detected!")
        ;code to deal with error here
    EndIf
EndFunc
Edited by Paulie
Posted

No. Functions are the only way.

Aww heck... Oh well... (HA, just found the Help entry on GoTo... OK)

Like this:

AdlibEnable("Check4Error")

;Code here

Func Check4Error()
    If WinGetHandle("")<>$handle And WinGetTitle("")="Rate Calculator" Then
        MsgBox(0,"Aha!","Error box detected!")
        ;code to deal with error here
    EndIf
EndFunc
Yes........ YES!

I KNEW there was a reason I liked AdLibs as a kid..........

Everseeker

Posted (edited)

Ummm. followup question...

Say I have this...

AdlibEnable("Check4Error")

Command1

Command2

Command3

Command4

Command5

Command6

Command7

Command8

exit

and an "error" is encountered during the execution of Command5

after handling the error, do I return to:

Before command 1

Before Command 5

After Command 5

Edited by everseeker

Everseeker

Posted (edited)

and an "error" is encountered during the execution of Command5

after handling the error, do I return to:

Before command 1

Before Command 5

After Command 5

Not sure but I will throw a lucky guess at after command 5

(HA, just found the Help entry on GoTo... OK)

Are you using autoit2? Because it was removed in V3.

The help file:

Gone. It's evil. No, you can't ask why - it just is. It's like that lump of rock they find in the microwave at the end of the film Time Bandits :)

Edited by monoceres

Broken link? PM me and I'll send you the file!

Posted (edited)

Not sure but I will throw a lucky guess at after command 5

Are you using autoit2? Because it was removed in V3.

I was referring to the line on Goto I found in help :

Gone. It's evil. No, you can't ask why - it just is. It's like that lump of rock they find in the microwave at the end of the film Time Bandits :)

I too am guessing that it's after command 5

So... If I , on getting this error, wherever I am in my main loop, want to cease firther processing and go to command 8... do I need to code thusly?

Global $Killbit="F"
AdlibEnable("Check4Error")
While 1=1
  While $Killbit="F" 
  Command1
  Wend

  While $Killbit="F" 
  Command2
  Wend

  While $Killbit="F" 
  Command3
  Wend

  While $Killbit="F" 
  Command4
  Wend

  While $Killbit="F" 
  Command5
  Wend

  While $Killbit="F" 
  Command6
  Wend

  While $Killbit="F" 
  Command7
  Wend

  While $Killbit="T" 
  Command8
  ExitLoop(2)
  Wend

wend

Command etc....
...
exit

Func Check4Error
$Killbit="T"
EndFunc

That seems to be pretty awkward.....

Edited by everseeker

Everseeker

Posted (edited)

OK, Have a windows application... It's running happily along, getting rates fed to it by me, via autoit3... life is good...

I feeling suspicious today - what, more precisely does your script do?

Have you been having success hacking the World Bank, that "life is good" ? Post your real code and prove me wrong. We all hereby promise to honor whatever copyrights you may really have to it.

Edited by Squirrely1

Das Häschen benutzt Radar

Posted

I feeling suspicious today - what, more precisely does your script do?

Have you been having success hacking the World Bank, that "life is good" ? Post your real code and prove me wrong. We all hereby promise to honor whatever copyrights you may really have to it.

HA... and again I say HA

I work for Humana... the Rate Calculator is a tool that is used by our call centers to quote rates to customers, based on Age, Smoker status, and a bunch of other factors.

My job is to feed this tool a LOT of dummy data, checking the output against tables of correct values.

There are records for every combination of families, Singles, Medicaid.. for every zip code. And every combination of option for each plan (Deductables, Perscrip med upgrades, etc...

THOUSANDS of the little puppies.... and they all need to run once every 90 days......

I can post the script... sure...

But it won't run without the RC Tool... and THAT would be problematical (Among other problems is the fact that the source DB is +2GB.... a bit large

Everseeker

Posted

A solution could be to put Command8 in a function and then call the function from the error func.

But that would STILL return me to the interior script... I need to abort the loop, soon as I get the error... and STAY out (until I get the next record.....)

Everseeker

Posted (edited)

Okay - this particular scam is sanctioned by the state and therefore theoretically legitimate: the health care industry of the United States. Local governments sometime used to just tax the mobsters in the 1940s, instead of arresting them.

No really - many people do still survive a modern-day visit to a hospital in the U.S. Then again, also to a witch doctor in the Carribbean.

No really - I confess - it seems like a wonderful and fully legitimate programming project to us now.

Edited by Squirrely1

Das Häschen benutzt Radar

Posted (edited)

Okay - this particular scam is sanctioned by the state and therefore theoretically legitimate: the health care industry of the United States. Local governments sometime used to just tax the mobsters in the 1940s, instead of arresting them.

No really - many people do still survive a modern-day visit to a hospital in the U.S. Then again, also to a witch doctor in the Carribbean.

No really - I confess - it seems like a wonderful and fully legitimate programming project to us now.

Just cuz......

here it is in all its uglyness....

[font="Verdana"]#cs ----------------------------------------------------------------------------
 
 Title:   RCBulkTest.au3
 AutoIt Version: 3.2.10.0
 Author:         Patrick McCarthy
 Company:     HumanaOne
 
 Script Function:
 Bulk Rate test for Rate Calculator
 
 Script Version: 0.0.7
 Initiated:  01/03/08
 Last Update: 03/23/08
 
 *** ExcelCOM_UDF.au3  Microsoft Excel COM UDF library for AutoIt v3
 *** Current Ver:  1.4
 *** Thanks to SEO aka Locodarwin, DaLiMan, Stanley Lim, MikeOsdx, MRDev, big_daddy, and PsaltyDS
#ce ----------------------------------------------------------------------------
#cs ----------------------------------------------------------------------------
 MasterArray Contents
 (Fields from Spreadsheet)
 1 =  Case #
 2 =  Effective Date
 3 =  Issue State
 4 =  Res. State
 5 =  Zip
 6 =  Primary Age, 7 = Primary Gender, 8 = Primary Smoker, 9 = Primary Rateup
 10 = Spouse Age, 11 = Spouse Gender, 12 = Spouse Smoker, 13 = Spouse Rateup
 14 = Child1 Age, 15 = Child1 Rateup
 16 = Child2 Age, 17 = Child2 Rateup
 18 = Child3 Age, 19 = Child3 Rateup
 20 = Child4 Age, 21 = Child4 Rateup
 22 = Child5 Age, 23 = Child5 Rateup
 24 = Child6 Age, 25 = Child6 Rateup
 26 = Child7 Age, 27 = Child7 Rateup
 28 = Child8 Age, 29 = Child8 Rateup
 30 = Child9 Age, 31 = Child9 Rateup
 32 = Child10 Age,33 = Child10 Rateup
 34 = Plan Type
 35 = Coins.
 36 = Coins. OON
 37 = Ded.
 38 = RX
 39 = OV Copay
 40 = Mat
 41 = SAB
 42 = LTM
 43 = Mental
 44 = Market Source
 45 = Payment Mode
 46 = Medicare Eligibility
 ---Validate the following
 47 = Primary Rate
 48 = Spouse Rate
 49 = Child1 Rate, 50 = Child2 Rate, 51 = Child3 Rate, 52 = Child4 Rate, 53 = Child5 Rate
 54 = Child6 Rate, 55 = Child7 Rate, 56 = Child8 Rate, 57 = Child9 Rate, 58 = Child10 Rate
 59 = Total Rate
 60 = Total Monthly Rate
 ---End Validation range
 
 (Added by routine)
 61 = GenderChild1, 62 = GenderChild2, 63 = GenderChild3, 64 = GenderChild4, 65 = GenderChild5
 66 = GenderChild6, 67 = GenderChild7, 68 = GenderChild8, 69 = GenderChild9, 70 = GenderChild10
 71 = Notes (Pass or details of failure)
#ce ----------------------------------------------------------------------------
$g_szVersion = "RCBulkTest.au3"
If WinExists($g_szVersion) Then Exit ; It's already running
AutoItWinSetTitle($g_szVersion)[/font][font="Verdana"]Opt("GUIOnEventMode", 1)
#include <GUIConstants.au3>  ; Load the standard Constants pack
#include <ExcelCOM_UDF.au3>  ; Include the Microsoft Excel COM UDF library for AutoIt v3
#include <Math.au3>          ; Include the standard Math pack
#Include <GuiComboBox.au3>
Global $Counter = 1
Global $TypeOfRow = 1
Global $array[10]
Global $Null = ""
Global $AbortRow = "False"
Global $DOBM = 0
Global $DOBD = 0
Global $DOBY = 0
Global $CandidatePlan = "xyz"
Global $GettingOut = "False"
Global $x = 1
Global $y = 1
Global $z = 1
Global $SinFamDeductable = "0"
; Press Esc to terminate script, Pause/Break to "pause"
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")[/font][font="Verdana"]; Open the Excel file
Global $oExcel = _ExcelBookOpen(FileOpenDialog("Load Excel Data File", "::{450D8FBA-AD25-11D0-98A8-0800361B1103}", "Data(*.xls)", 1, "RC Test Cases.xls"), 1, "False")[/font][font="Verdana"]; Load the entire Spreadsheet to the master array
ConsoleWrite("Load The Excel Data" & @CRLF)
$array = _excelSheetUsedRangeGet($oExcel, 1)
Global $Rows = ($array[3])
Global $Cols = ($array[2])
Global $MasterArray[$Rows][$Cols]
$MasterArray = _ExcelReadSheetToArray($oExcel)
If (@error = 0) And (UBound($MasterArray, 0) = 2) Then
 ReDim $MasterArray[$Rows + 1][$Cols + 13]
Else
 MsgBox(1, "Awk", "The Sky is falling!")
 Exit
EndIf[/font][font="Verdana"];Hide Excel
_Excelhide($oExcel)[/font][font="Verdana"]; Load the random child sex's
ConsoleWrite("Load The random Gender Specs for the kids" & @CRLF)
For $index = 1 To $Rows
 For $KidIndex = 61 To 70
  $MasterArray[$index][$KidIndex] = PickGender()
 Next
 $MasterArray[$index][71] = "Pass"
Next[/font][font="Verdana"]
; Getting data from array, fill in form
While $Counter <= $Rows
 
 ;Launch Rate Calc
 Run("C:\Program Files\Humana\Rate Calculator 8\RateCalculator8.exe", "")
 
 ConsoleWrite("Counter is at " & $Counter & " of " & $Rows & " rows. Time is " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)
 ;Need to do this cuz of the *#&$#(@ Nag screen WinWait("HumnaaOne Rate Calculator", "", 5)
 ControlClick("HumnaaOne Rate Calculator", "", "[CLASSNN:BUTTON1; INSTANCE:1]")
 
 MouseMove(1, 1, 30)
 ;MouseClick("Left", 840, 530, 1, 10)
 
 WinWaitActive("Rate Calculator", "Available Profiles") ;Log in as first user
 ConsoleWrite("Load The Profile" & @CRLF)
 Sleep(300)
 Send("{DOWN}{TAB}{ENTER}") WinWait("Rate Calculator", "Primary")
 $handle = WinGetHandle("Rate Calculator")
 ; Zip code
 ControlSetText("Rate Calculator", "", "[CLASSNN:WindowsForms10.EDIT.app.0.378734a1; INSTANCE:1]", $MasterArray[$Counter][5])
 ;Updates on leaving the control, so...
 ControlFocus("Rate Calculator", "", "[CLASSNN:WindowsForms10.EDIT.app.0.378734a1; INSTANCE:1]")
 Send("{TAB 3}") 
 ; EffectiveDate (2)
 $EffDateToUse = createeffectivedate()
 Send($EffDateToUse)
 Send("{TAB 12}")
 
 ; Begin adding people
 $TypeOfRow = findtypeofrow()
 $AbortRow = "False"
 Select
  Case $TypeOfRow = 1; Primary Only
   ConsoleWrite("Type of row: Primary only" & @CRLF)
   
   ; Primary part
   EnterAdult(0)
   
   ; Move to Get a Quote button
   AdlibEnable("myadlib")
   ControlClick("Rate Calculator", "", "[TEXT:Get A Quote]")
   ConsoleWrite("Move to Choose Plans page." & @CRLF)
   
   
  Case $TypeOfRow = 2; Primary and Spouse
   ConsoleWrite("Type of row: Primary and spouse only" & @CRLF)
   
   ; Primary part
   EnterAdult(0)
   
   ; Spouse part
   Send("{TAB 3}")
   EnterAdult(4)
   
   ; Move to Get a Quote button
   
   ControlClick("Rate Calculator", "", "[TEXT:Get A Quote]")
   ConsoleWrite("Move to Choose Plans page." & @CRLF)
   ; Send("{TAB 26}")   
  Case $TypeOfRow = 3; Primary, Spouse, and 1 child
   ConsoleWrite("Type of row: Primary, Spouse, and 1 child" & @CRLF)   ; Primary part
   EnterAdult(0)
   
   ; Spouse part
   Send("{TAB 3}")
   EnterAdult(4)
   
   ; Child 1 part
   Send("{TAB 3}")
   EnterKid(1)
   
   ; Move to Get a Quote button
   ControlClick("Rate Calculator", "", "[TEXT:Get A Quote]")
   ConsoleWrite("Move to Choose Plans page." & @CRLF)
   
  Case $TypeOfRow = 4; Primary, Spouse, and n children
   ConsoleWrite("Type of row: Primary, Spouse, and n children" & @CRLF)
   
   ; Primary part
   EnterAdult(0)
   
   ; Spouse part
   Send("{TAB 12}")
   EnterAdult(4)
   
   ; Child 1 part
   Send("{TAB 12}")
   EnterKid(1)
   
   ; Child 2-n part
   For $kidnum = 2 To CountKids()
    ControlClick("Rate Calculator", "", "[TEXT:Add Child]")
    Sleep(100)
    Send("+{TAB 10}")
    Sleep(100)
    
    ; Enter kid data
    EnterKid($kidnum)
   Next
   
   ; Move to Get a Quote button
   ControlClick("Rate Calculator", "", "[TEXT:Get A Quote]")
   ConsoleWrite("Move to Choose Plans page." & @CRLF)
   
  Case $TypeOfRow = 5; Primary and 1 child
   ConsoleWrite("Type of row: Primary and 1 child" & @CRLF)
   
   ; Primary part
   EnterAdult(0)
   
   ; Child 1 part
   Send("{TAB 15}")
   EnterKid(1)
   
   ; Move to Get a Quote button
   ControlClick("Rate Calculator", "", "[TEXT:Get A Quote]")
   ConsoleWrite("Move to Choose Plans page." & @CRLF)
   
  Case $TypeOfRow = 6; Primary and n children
   ConsoleWrite("Type of row: Primary and n children" & @CRLF)
   
   ; Primary part
   EnterAdult(0)
   
   ; Child 1 part
   Send("{TAB 15}")
   EnterKid(1)
   
   ;Child 2 - n part
   For $kidnum = 2 To CountKids()
    ControlClick("Rate Calculator", "", "[TEXT:Add Child]")
    Sleep(100)
    Send("+{TAB 10}")
    Sleep(100)
    ; Enter kid data
    EnterKid($kidnum)
   Next
   
   ; Move to Get a Quote button
   ControlClick("Rate Calculator", "", "[TEXT:Get A Quote]")
   ConsoleWrite("Move to Choose Plans page." & @CRLF)   
   
  Case $TypeOfRow = 7; Primary who's too old
   ; Only Primary, and he's too old... abort this one
   ConsoleWrite("Type of row: No one (Pri too old)")
   $AbortRow = "True"
   
   
  Case $TypeOfRow = 8; = Primary and Spouse, Pri too old
   ConsoleWrite("Type of row: Spouse Only(Pri too old)")
   
   ; Primary part (Moving Spouse data to Primary field)
   
   $MasterArray[$Counter][6] = $MasterArray[$Counter][10]
   $MasterArray[$Counter][7] = $MasterArray[$Counter][11]
   $MasterArray[$Counter][8] = $MasterArray[$Counter][12]
   $MasterArray[$Counter][9] = $MasterArray[$Counter][13]
   
   EnterAdult(0)
   
   ; Move to Get a Quote button
   ControlClick("Rate Calculator", "", "[TEXT:Get A Quote]")
   ConsoleWrite("Move to Choose Plans page." & @CRLF)   
  Case $TypeOfRow = 9; = Primary, Spouse, and 1 child Pri too old
   ConsoleWrite("Type of row:  Spouse, and 1 child (Pri too old)" & @CRLF)
   
   ; Primary part (Moving Spouse data to Primary field)
   
   $MasterArray[$Counter][6] = $MasterArray[$Counter][10]
   $MasterArray[$Counter][7] = $MasterArray[$Counter][11]
   $MasterArray[$Counter][8] = $MasterArray[$Counter][12]
   $MasterArray[$Counter][9] = $MasterArray[$Counter][13]
   EnterAdult(0)
   
   ; Child 1 part
   Send("{TAB 15}")
   EnterKid(1)
   
   ; Move to Get a Quote button
   ControlClick("Rate Calculator", "", "[TEXT:Get A Quote]")
   ConsoleWrite("Move to Choose Plans page." & @CRLF)   
   
  Case $TypeOfRow = 10; = Primary, Spouse, and n children Pri too old
   ConsoleWrite("Type of row: Spouse, and n children(Pri too old)" & @CRLF)
   
   ; Primary part
   ; Primary part (Moving Spouse data to Primary field)
   
   $MasterArray[$Counter][6] = $MasterArray[$Counter][10]
   $MasterArray[$Counter][7] = $MasterArray[$Counter][11]
   $MasterArray[$Counter][8] = $MasterArray[$Counter][12]
   $MasterArray[$Counter][9] = $MasterArray[$Counter][13]
   EnterAdult(0)
   
   ; Child 1 part
   Send("{TAB 15}")
   EnterKid(1)
   
   ; Child 2-n part
   For $kidnum = 2 To CountKids()
    ControlClick("Rate Calculator", "", "[TEXT:Add Child]")
    Sleep(100)
    Send("+{TAB 10}")
    Sleep(100)
    
    ; Enter kid data
    EnterKid($kidnum)
   Next
   
   ; Move to Get a Quote button
   ControlClick("Rate Calculator", "", "[TEXT:Get A Quote]")
   ConsoleWrite("Move to Choose Plans page." & @CRLF)   Case $TypeOfRow = 11; = Primary and 1 child Pri too old
   ;Hold for RC to correct Child Only app code
   ConsoleWrite("Abort for now. Hold for RC to correct Child Only app code" & @CRLF)
   $AbortRow = "True"  Case $TypeOfRow = 12; = Primary and n children Pri too old
   ;Hold for RC to correct Child Only app code
   ConsoleWrite("Abort for now. Hold for RC to correct Child Only app code" & @CRLF)
   $AbortRow = "True"  Case $TypeOfRow = 13; = Child Only App, 1 child
   ;Hold for RC to correct Child Only app code
   ConsoleWrite("Abort for now. Hold for RC to correct Child Only app code" & @CRLF)
   $AbortRow = "True"  Case $TypeOfRow = 14; = Child Only App, n children
   ;Hold for RC to correct Child Only app code
   ConsoleWrite("Abort for now. Hold for RC to correct Child Only app code" & @CRLF)
   $AbortRow = "True"
   
  Case $TypeOfRow = 15; = Primary and Spouse, Both too old
   ; Only too old... abort this one
   ConsoleWrite("Aborting...No one eligible (Pri too old)" & @CRLF)
   $AbortRow = "True"  Case $TypeOfRow = 16; = Primary, Spouse, and 1 child Both too old
   ;Hold for RC to correct Child Only app code
   ConsoleWrite("Abort for now. Hold for RC to correct Child Only app code" & @CRLF)
   $AbortRow = "True"  Case $TypeOfRow = 17; = Primary, Spouse, and n children Both too old
   ;Hold for RC to correct Child Only app code
   ConsoleWrite("Abort for now. Hold for RC to correct Child Only app code" & @CRLF)
   $AbortRow = "True" EndSelect ; GetAQuote **********************************Meat of the loop************************
 If $AbortRow = "False"  Then
  
  WinWait("Rate Calculator", $MasterArray[$Counter][34])
  ; Select a plan, select Customize and compare to get to page 3
  ControlClick("Rate Calculator", "", "[CLASSNN:WindowsForms10.BUTTON.app.0.378734a24]")
  ;Send("{tab 13}")
  ;Send("{enter}")
  ConsoleWrite("Click to select Customize and Compare Selected Plans" & @CRLF)
  ControlClick("Rate Calculator", "", "[CLASSNN:WindowsForms10.BUTTON.app.0.378734a20]")
  
  
  WinWait("Rate Calculator", "Total Premium")
  ConsoleWrite("Customize and compare Window is here" & @CRLF)  ; From form , scrape off all needed data
  ConsoleWrite("Picking plan: " & $MasterArray[$Counter][34] & @CRLF)
  ComboBox_SelectString("Rate Calculator", "", _
    "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a8]", $MasterArray[$Counter][34])
  
  $SinFamDeductable = Number($MasterArray[$Counter][37])
  If $TypeOfRow <> 1 And ($MasterArray[$Counter][34] = "AUTOGRAPH Total Plus Rx / H$A"  Or $MasterArray[$Counter][34] = "AUTOGRAPH Share 80 / H$A"  Or $MasterArray[$Counter][34] = "AUTOGRAPH Total / H$A") Then
   $SinFamDeductable = $SinFamDeductable * 2
  EndIf
  
  $SinFamDeductable = "$" & StringMid(String($SinFamDeductable), 1, 1) & "," & StringMid(String($SinFamDeductable), 2, 3)
  If $TypeOfRow = 1 Then
   $SinFamDeductable = $SinFamDeductable & " - Single"
  Else
   $SinFamDeductable = $SinFamDeductable & " - Family"
  EndIf
  ConsoleWrite($SinFamDeductable & @CRLF)
  ComboBox_SelectString("Rate Calculator", "", _
    "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a13]", $SinFamDeductable)
  If @error = 1 Then
   ConsoleWrite("Value passed: " & $MasterArray[$Counter][37] & " Value calculated: " & $SinFamDeductable & " Not found" & @CRLF)
   $MasterArray[$Counter][71] = "Deductable Value passed: " & $MasterArray[$Counter][37] & ". Value calculated: " & $SinFamDeductable & " Not found"
  EndIf
  #cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   To add:
   
   
   Lifetime max is column 42
   Combobox 14(Yes / No... Yes = {Down}, no = noop)
   
   Mental is column 43
   Button 26 Click To Select If yes
   
   Supp Accident is Column 41
   Combobox 15(Formatted: $x, xxx)
   
   Re - Calculate is Button 21
   Expand is Button 22
   
   {Read data goes here}
   
   Pause For 10 seconds
   
  #ce ----------------------------------------------------------------------------  Sleep(2000)
 EndIf
 MsgBox(1, "Loop Track", "Completed Record # " & $Counter, 2)
 ControlClick("Rate Calculator", "", "[CLASSNN:WindowsForms10.BUTTON.app.0.378734a5; INSTANCE:5]")
 $Counter = $Counter + 1
WEnd
; When all lines have been processed, close RC; Pull Excel file back up; Create an output page; Dump results to output page, coloring data as needed; Close Excel
_excelBookClose($oExcel, 1); rovide summary data
ConsoleWrite(@CRLF & _VarDump($MasterArray)); exit
Exit  
#cs ----------------------------------------------------------------------------
 Following is the function collection...
#ce ----------------------------------------------------------------------------
Func myadlib()
 If WinGetHandle("") <> $handle And WinGetTitle("") = "Rate Calculator"  Then
  MsgBox(0, "Aha!", "Error box detected!")
  $AbortRow = "True"
  ;code to deal with error here
 EndIfEndFunc   ;==>myadlib
; -------------------------------------------------------------------------------Func ComboBox_SelectString($winTitle, $winText, $control, $option)
 Local $hWnd = ControlGetHandle($winTitle, $winText, $control)
 Local $index = _GUICtrlComboBox_FindString($hWnd, $option) If $index = -1 Then
  ConsoleWrite($option & " not found" & @CRLF)
  SetError(1)
  Return False
 EndIf If $index = 0 Then
  ; If the item is the first in the list, use hotkeys to navigate to it
  ControlSend($winTitle, $winText, $hWnd, "^{PGUP}")
 Else
  ; Select the item right before the target index, then send down
  _GUICtrlComboBox_SetCurSel($hWnd, $index - 1)
  ControlSend($winTitle, $winText, $hWnd, "{DOWN}")
 EndIf
 Return True
EndFunc   ;==>ComboBox_SelectString
; -------------------------------------------------------------------------------Func EnterAdult($TypeOfAdult)
 ; $typeofadult = 0 -> Primary
 ; $typeofadult = 4 -> Spouse
 Sleep(300)
 If $TypeOfAdult = 0 Then ; Primary Entry
  ConsoleWrite("Primary Age: " & $MasterArray[$Counter][6] & " Gender: " & $MasterArray[$Counter][7] & " Smoker?: " & $MasterArray[$Counter][8] & " Rate UP=" & $MasterArray[$Counter][9] & @CRLF)
  
  ; Gender (7)
  If $MasterArray[$Counter][7 + $TypeOfAdult] = "M"  Then
   ComboBox_SelectString("Rate Calculator", "", _
     "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a3]", "Male")
   Sleep(300)
  Else
   ComboBox_SelectString("Rate Calculator", "", _
     "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a3]", "Female")
   ;Sleep(300)
  EndIf
  
  ; Age (6)
  ;ControlSetText("Rate Calculator", "", "[CLASSNN:WindowsForms10.EDIT.app.0.378734a15; INSTANCE:15]", $MasterArray[$Counter][6 + $TypeOfAdult])
  ;Sleep(300)
  
  ; Tobacco (8)
  If $MasterArray[$Counter][8 + $TypeOfAdult] = "S"  Then
   ComboBox_SelectString("Rate Calculator", "", _
     "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a2]", "Y")
   ;Sleep(300)
  Else
   ComboBox_SelectString("Rate Calculator", "", _
     "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a2]", "N")
   ;Sleep(300)
   
  EndIf
  
  ; RateUp(9)
  If Number($MasterArray[$Counter][9 + $TypeOfAdult]) <> 0 Then
   ComboBox_SelectString("Rate Calculator", "", _
     "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a1]", String(Number($MasterArray[$Counter][9 + $TypeOfAdult]) * 100))
  EndIf
  ;Sleep(300)
  
 Else ; Spouse entry
  ConsoleWrite("Spouse Age: " & $MasterArray[$Counter][10] & " Gender: " & $MasterArray[$Counter][11] & " Smoker?: " & $MasterArray[$Counter][12] & " Rate UP=" & $MasterArray[$Counter][13] & @CRLF)
  Sleep(300)
  ; Gender (7)
  If $MasterArray[$Counter][7 + $TypeOfAdult] = "M"  Then
   ComboBox_SelectString("Rate Calculator", "", _
     "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a6]", "Male")
   ;Sleep(300)
  Else
   ComboBox_SelectString("Rate Calculator", "", _
     "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a6]", "Female")
   ;Sleep(300)
  EndIf
  
  ; Age (6)
  ControlSetText("Rate Calculator", "", "[CLASSNN:WindowsForms10.EDIT.app.0.378734a23]", $MasterArray[$Counter][6 + $TypeOfAdult])
  ;Sleep(300)
  
  ; Tobacco (8)
  If $MasterArray[$Counter][8 + $TypeOfAdult] = "S"  Then
   ComboBox_SelectString("Rate Calculator", "", _
     "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a5]", "Y")
   ;Sleep(300)
  Else
   ComboBox_SelectString("Rate Calculator", "", _
     "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a5]", "N")
   ;Sleep(300)
   
  EndIf
  
  ; RateUp(9)
  If Number($MasterArray[$Counter][9 + $TypeOfAdult]) <> 0 Then
   ComboBox_SelectString("Rate Calculator", "", _
     "[CLASSNN:WindowsForms10.COMBOBOX.app.0.378734a4]", String(Number($MasterArray[$Counter][9 + $TypeOfAdult]) * 100))
   ;Sleep(300)
  EndIf
 EndIfEndFunc   ;==>EnterAdult
; -------------------------------------------------------------------------------Func EnterKid($KidRefNum)
 ; $kidrefnum is the "kid number offset"... from 1 to 10
 
 ConsoleWrite("Child # " & $KidRefNum)
 
 ; Gender (Base 61)
 
 Send($MasterArray[$Counter][$KidRefNum + 60])
 Sleep(100)
 
 ; Age (Base 14)
 Send("{TAB}")
 If $MasterArray[$Counter][($KidRefNum * 2) + 12] >= 1 Then
  Send($MasterArray[$Counter][($KidRefNum * 2) + 12])
  ConsoleWrite(" Age: " & $MasterArray[$Counter][($KidRefNum * 2) + 12] & " Gender: " & $MasterArray[$Counter][$KidRefNum + 60] & " Rate UP=" & $MasterArray[$Counter][($KidRefNum * 2) + 13] & @CRLF)
  Send("{TAB 4}")
 Else
  ;move to month
  Send("{TAB}")
  $DOBM = StringMid($MasterArray[$Counter][2], 5, 2) - 4
  $DOBD = 15
  $DOBY = StringMid($MasterArray[$Counter][2], 1, 4)
  If $DOBM < 1 Then
   $DOBM = $DOBM + 6
   $DOBY = $DOBY - 1
  EndIf
  Send($DOBM)
  Send("{TAB}")
  Send($DOBD)
  Send("{TAB}")
  Send($DOBY)
  Send("{TAB}")
  ConsoleWrite(" DOB: " & $DOBM & "/" & $DOBD & "/" & $DOBY & " Gender: " & $MasterArray[$Counter][$KidRefNum + 60] & " Rate UP=" & $MasterArray[$Counter][($KidRefNum * 2) + 13] & @CRLF) EndIf
 ;Sleep(300)
 
 ; RateUp(Base 15)
 Send("{TAB 3}")
 Send($MasterArray[$Counter][($KidRefNum * 2) + 13])
 
 
EndFunc   ;==>EnterKid
; -------------------------------------------------------------------------------Func PickGender()
 If Random(0, 2) <= 1 Then
  Return "M"
 Else
  Return "F"
 EndIf
EndFunc   ;==>PickGender
; -------------------------------------------------------------------------------Func createeffectivedate()
 ;  $MasterArray[$Counter][2]
 Return StringMid($MasterArray[$Counter][2], 5, 2) & "/" & StringMid($MasterArray[$Counter][2], 7, 2) & "/" & StringMid($MasterArray[$Counter][2], 1, 4)
EndFunc   ;==>createeffectivedate
; -------------------------------------------------------------------------------Func findtypeofrow()
 #cs ----------------------------------------------------------------------------
  1 = Primary
  2 = Primary and Spouse
  3 = Primary, Spouse, and 1 child
  4 = Primary, Spouse, and n children
  5 = Primary and 1 child
  6 = Primary and n children
  7 = Primary who's too old
  8 = Primary and Spouse, Pri too old
  9 = Primary, Spouse, and 1 child Pri too old
  10 = Primary, Spouse, and n children Pri too old
  11 = Primary and 1 child Pri too old
  12 = Primary and n children Pri too old
  13 = Child Only App, 1 child
  14 = Child Only App, n children
  15 = Primary and Spouse, Both too old
  16 = Primary, Spouse, and 1 child Both too old
  17 = Primary, Spouse, and n children Both too old
  
 #ce ---------------------------------------------------------------------------- Local $numkids = 0
 $numkids = CountKids() ConsoleWrite("Number of kids=" & $numkids & ". " & @CRLF)
 
 Select
  Case $MasterArray[$Counter][10] = $Null And $MasterArray[$Counter][6] >= 18 And $MasterArray[$Counter][6] < 65 And $numkids = 0
   Return 1
  Case $MasterArray[$Counter][10] <> $Null And $MasterArray[$Counter][6] >= 18 And $MasterArray[$Counter][6] < 65 And $numkids = 0
   Return 2
  Case $MasterArray[$Counter][10] <> $Null And $MasterArray[$Counter][6] >= 18 And $MasterArray[$Counter][6] < 65 And $numkids = 1
   Return 3
  Case $MasterArray[$Counter][10] <> $Null And $MasterArray[$Counter][6] >= 18 And $MasterArray[$Counter][6] < 65 And $numkids > 1
   Return 4
  Case $MasterArray[$Counter][10] = $Null And $MasterArray[$Counter][6] >= 18 And $MasterArray[$Counter][6] < 65 And $numkids = 1
   Return 5
  Case $MasterArray[$Counter][10] = $Null And $MasterArray[$Counter][6] >= 18 And $MasterArray[$Counter][6] < 65 And $numkids > 1
   Return 6
  Case $MasterArray[$Counter][10] = $Null And $MasterArray[$Counter][6] >= 65 And $numkids = 0
   Return 7
  Case $MasterArray[$Counter][10] <> $Null And $MasterArray[$Counter][6] >= 65 And $numkids = 0
   Return 8
  Case $MasterArray[$Counter][10] <> $Null And $MasterArray[$Counter][6] >= 65 And $numkids = 1
   Return 9
  Case $MasterArray[$Counter][10] <> $Null And $MasterArray[$Counter][6] >= 65 And $numkids > 1
   Return 10
  Case $MasterArray[$Counter][10] = $Null And $MasterArray[$Counter][6] >= 65 And $numkids = 1
   Return 11
  Case $MasterArray[$Counter][10] = $Null And $MasterArray[$Counter][6] >= 65 And $numkids > 1
   Return 12
  Case $MasterArray[$Counter][10] = $Null And $MasterArray[$Counter][6] < 18 And $numkids = 0
   Return 13
  Case $MasterArray[$Counter][10] = $Null And $MasterArray[$Counter][6] < 18 And $numkids > 0
   Return 14
  Case $MasterArray[$Counter][10] >= 65 And $MasterArray[$Counter][6] >= 65 And $numkids = 0
   Return 15
  Case $MasterArray[$Counter][10] >= 65 And $MasterArray[$Counter][6] >= 65 And $numkids = 1
   Return 16
  Case $MasterArray[$Counter][10] >= 65 And $MasterArray[$Counter][6] >= 65 And $numkids > 1
   Return 17
   
  Case Else
   ConsoleWrite("There are Ghosts in the machine I tell ya.... Ghosts! " & @CRLF) EndSelectEndFunc   ;==>findtypeofrow
; -------------------------------------------------------------------------------Func CountKids()
 #cs ----------------------------------------------------------------------------
  Kid count for the row is from 0 to 10
 #ce ----------------------------------------------------------------------------
 Select
  Case $MasterArray[$Counter][32] <> $Null
   Return 10
  Case $MasterArray[$Counter][30] <> $Null
   Return 9
  Case $MasterArray[$Counter][28] <> $Null
   Return 8
  Case $MasterArray[$Counter][26] <> $Null
   Return 7
  Case $MasterArray[$Counter][24] <> $Null
   Return 6
  Case $MasterArray[$Counter][22] <> $Null
   Return 5
  Case $MasterArray[$Counter][20] <> $Null
   Return 4
  Case $MasterArray[$Counter][18] <> $Null
   Return 3
  Case $MasterArray[$Counter][16] <> $Null
   Return 2
  Case $MasterArray[$Counter][14] <> $Null
   Return 1
   
  Case Else
   Return 0
 EndSelect
EndFunc   ;==>CountKids
; -------------------------------------------------------------------------------Func TogglePause()
 $Paused = Not $Paused
 While $Paused
  Sleep(100)
 WEnd
 ToolTip("")
EndFunc   ;==>TogglePause
; -------------------------------------------------------------------------------Func Terminate()
 ; Close Excel
 _excelBookClose($oExcel, 1)
 Exit 0
EndFunc   ;==>Terminate
; -------------------------------------------------------------------------------
Func _VarDump(ByRef $vVar, $sIndent = '')
 Select
  Case IsDllStruct($vVar)
   Return 'Struct(' & DllStructGetSize($vVar) & ')'
  Case IsArray($vVar)
   Return 'Array' & @CRLF & _VarDumpArray($vVar, $sIndent)
  Case IsBinary($vVar)
   Return 'Binary(' & BinaryLen($vVar) & ')'
  Case IsBool($vVar)
   Return 'Boolean(' & $vVar & ')'
  Case IsFloat($vVar)
   Return 'Float(' & $vVar & ')'
  Case IsHWnd($vVar)
   Return 'HWnd(' & $vVar & ')'
  Case IsInt($vVar)
   Return 'Integer(' & $vVar & ')'
  Case IsKeyword($vVar)
   Return 'Keyword(' & $vVar & ')'
  Case IsObj($vVar)
   Return 'Object(' & ObjName($vVar) & ')'
  Case IsString($vVar)
   Return 'String(' & StringLen($vVar) & ') ' & $vVar
  Case Else
   Return 'Unknown(' & $vVar & ')'
 EndSelect
EndFunc   ;==>_VarDump
; -------------------------------------------------------------------------------Func _VarDumpArray(ByRef $aArray, $sIndent = '')
 Local $sDump
 Local $sArrayFetch, $sArrayRead, $bDone
 Local $iSubscripts = UBound($aArray, 0)
 Local $aUBounds[$iSubscripts]
 Local $aCounts[$iSubscripts]
 $iSubscripts -= 1
 For $i = 0 To $iSubscripts
  $aUBounds[$i] = UBound($aArray, $i + 1) - 1
  $aCounts[$i] = 0
 Next
 $sIndent &= @TAB
 While 1
  $bDone = True
  $sArrayFetch = ''
  For $i = 0 To $iSubscripts
   $sArrayFetch &= '[' & $aCounts[$i] & ']'
   If $aCounts[$i] < $aUBounds[$i] Then $bDone = False
  Next  $sArrayRead = Execute('$aArray' & $sArrayFetch)
  If @error Then
   ExitLoop
  Else
   $sDump &= $sIndent & $sArrayFetch & ' => ' & _VarDump($sArrayRead, $sIndent)
   If Not $bDone Then
    $sDump &= @CRLF
   Else
    Return $sDump
   EndIf
  EndIf  For $i = $iSubscripts To 0 Step - 1
   $aCounts[$i] += 1
   If $aCounts[$i] > $aUBounds[$i] Then
    $aCounts[$i] = 0
   Else
    ExitLoop
   EndIf
  Next
 WEnd
EndFunc   ;==>_VarDumpArray
[/font]
Edited by everseeker

Everseeker

Posted

Looks like a great project, dude. AutoIt'rs sometimes get accused of hacking - so we police the forum a little.

Das Häschen benutzt Radar

Posted

D*mn, I have been trying really hard to come up with a solution that doesn't involve adding at least one line of code to each statement in your loop...

I never thought I said this, but I miss goto :)

Broken link? PM me and I'll send you the file!

Posted

D*mn, I have been trying really hard to come up with a solution that doesn't involve adding at least one line of code to each statement in your loop...

I never thought I said this, but I miss goto :)

There MUST be a way to return from a function... to a different location.....

Everseeker

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...