anoig

Need help debugging _arrayadd function

2 posts in this topic

#1 ·  Posted

Hi all, 

First, I want to give a huge shout-out to the community. I'm completely self-taught, and have never had to actually ask a question before because the forum is that good at answering questions and explaining things. However, I'm kind of stumped here, and I've been stuck on this problem for almost a full day.

I'm working on a script to populate drafts of deeds at work. I have the main GUI and  a function (ctrl($n) and read()) for adding fields to find and data to replace it with to an array for later use with _word_docfindreplace. All of that works. However, due to the way I have the forms set up, I need to create additional fields and info based on the data that's there. Specifically, if there's only one buyer, I need to add the field [Buyer1&2] and the data in $aArray_Base for [Buyer 1]. I also need to add a field [Buyer 2] and have a blank data set in the next column over in the array, and I need to do the same for the Seller. To this end, the function parties() sets boolean variables $2buyers and $2sellers accordingly. Then, I have buyers() and sellers() to populate the data. 

The problem that I'm running into is that each function works... when ONLY the buyer 1 name field is filled, and when ONLY the seller 1 field is filled.

So if I fill Buyer 1 Name and save it, the data is populated correctly. But when I fill Buyer 1 and Seller 1 name, only the buyer 1 data populates correctly. Worse, when I fill several fields, neither populate correctly. I have no idea why this happens. I've added messageboxes to debug throughout the entire process and can't pinpoint what's causing the issue. The entire script is below. The function(s) in question are buyers() and sellers(). Only Sellers() has messageboxes throughout.

Can someone help walk me through what might be causing this and help me find a solution? Thanks a ton in advance, and sorry for the wall of text.

-Anoig

Spoiler
#include <ButtonConstants.au3> ;AutoIT plugins
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <Word.au3>
#include <ComboConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Users\Randy\Downloads\koda_1.7.3.0\Forms\KNDS.kxf
$KNDS = GUICreate("KNDS DocPrep Wizard", 727, 507, 540, 193)
$MainPage = GUICtrlCreateTab(8, 40, 708, 424)
$TabSheet1 = GUICtrlCreateTabItem("Property")
$Property = GUICtrlCreateGroup("Legal Description", 32, 80, 657, 153)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$InputLegal = GUICtrlCreateEdit("", 40, 96, 641, 129, $ES_WANTRETURN, 0)
GUICtrlSetTip(-1, "Full legal description from Schedule A of Title Commitment")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Buyer = GUICtrlCreateTabItem("Buyer")
$Buyer1Group = GUICtrlCreateGroup("Buyer 1", 24, 72, 329, 185)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$inputbuyer1 = GUICtrlCreateInput("", 120, 104, 217, 22)
GUICtrlSetTip(-1, "Bob Buyer, LLC")
$Buyersingle = GUICtrlCreateRadio("Single", 32, 136, 57, 17)
$BuyerMarried = GUICtrlCreateRadio("Married", 32, 160, 65, 17)
$BuyerLLC = GUICtrlCreateRadio("LLC", 32, 184, 57, 17)
$BuyerInc = GUICtrlCreateRadio("Inc.", 32, 208, 49, 17)
$inputbuyerentitystate = GUICtrlCreateInput("", 272, 208, 73, 22)
GUICtrlSetTip(-1, "Write out state name, e.g. Texas")
$Buyer1label = GUICtrlCreateLabel("Buyer 1 Name:", 32, 104, 75, 18)
$labelbuyerentitystate = GUICtrlCreateLabel("State (only if LLC or Inc.):", 136, 208, 127, 18)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Buyer2Group = GUICtrlCreateGroup("Buyer 2", 368, 72, 321, 185)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Buyer2label = GUICtrlCreateLabel("Buyer 2 Name:", 376, 104, 75, 18)
$InputBuyer2 = GUICtrlCreateInput("", 464, 104, 209, 22)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupBuyAdd = GUICtrlCreateGroup("Buyer's Address", 24, 264, 673, 185)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$labelbuyadd1 = GUICtrlCreateLabel("Address:", 32, 304, 49, 18)
$labelbuyadd2 = GUICtrlCreateLabel("City, State, Zip:", 32, 336, 81, 18)
$labelbuycounty = GUICtrlCreateLabel("County:", 32, 368, 41, 18)
$InputBuyerAdd1 = GUICtrlCreateInput("", 120, 304, 561, 22)
GUICtrlSetTip(-1, "123 Main Street")
$InputBuyerAdd2 = GUICtrlCreateInput("", 120, 336, 561, 22)
GUICtrlSetTip(-1, "City, State Zip")
$InputBuyerAdd3 = GUICtrlCreateInput("", 120, 368, 561, 22)
GUICtrlSetTip(-1, "County")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Seller = GUICtrlCreateTabItem("Seller")
$Group1 = GUICtrlCreateGroup("Seller 1", 26, 73, 329, 185)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$InputSeller1 = GUICtrlCreateInput("", 122, 105, 217, 22)
GUICtrlSetTip(-1, "Sally the Seller, LLC")
$Labelseller1 = GUICtrlCreateLabel("Seller 1 Name:", 34, 105, 73, 18)
$SellerMarried = GUICtrlCreateRadio("Married", 34, 161, 65, 17)
$SellerSingle = GUICtrlCreateRadio("Single", 34, 137, 57, 17)
$SellerLLC = GUICtrlCreateRadio("LLC", 34, 185, 57, 17)
$SellerInc = GUICtrlCreateRadio("Inc.", 34, 209, 49, 17)
$Label2 = GUICtrlCreateLabel("State (only if LLC or Inc.):", 138, 209, 127, 18)
$InputSellerEntityState = GUICtrlCreateInput("", 274, 209, 73, 22)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Seller 2", 372, 73, 321, 185)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label3 = GUICtrlCreateLabel("Seller 2 Name:", 380, 105, 73, 18)
$InputSeller2 = GUICtrlCreateInput("", 468, 105, 209, 22)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Seller's Address", 26, 265, 673, 185)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label4 = GUICtrlCreateLabel("Address:", 34, 305, 49, 18)
$Label5 = GUICtrlCreateLabel("City, State Zip:", 34, 337, 81, 18)
$Label6 = GUICtrlCreateLabel("County:", 34, 369, 41, 18)
$InputSellerAdd1 = GUICtrlCreateInput("", 122, 305, 561, 22)
GUICtrlSetTip(-1, "123 Main Street")
$InputSellerAdd2 = GUICtrlCreateInput("", 122, 337, 561, 22)
GUICtrlSetTip(-1, "City, State Zip")
$InputSellerAdd3 = GUICtrlCreateInput("", 122, 369, 561, 22)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Lender = GUICtrlCreateTabItem("Lender")
GUICtrlSetState(-1,$GUI_SHOW)
$Group5 = GUICtrlCreateGroup("Lender Info", 19, 73, 393, 161)
$Label7 = GUICtrlCreateLabel("Address:", 27, 129, 45, 17)
$Label8 = GUICtrlCreateLabel("City, State, Zip:", 27, 161, 81, 18)
$Label9 = GUICtrlCreateLabel("County:", 27, 193, 40, 17)
$InputLenderAdd1 = GUICtrlCreateInput("", 115, 129, 281, 21)
GUICtrlSetTip(-1, "123 Main Street")
$InputLenderAdd2 = GUICtrlCreateInput("", 115, 161, 281, 21)
GUICtrlSetTip(-1, "City, State, Zip")
$InputLenderAdd3 = GUICtrlCreateInput("", 115, 193, 281, 21)
GUICtrlSetTip(-1, "e.g. Tarrant County")
$Label1 = GUICtrlCreateLabel("Lender Name:", 27, 97, 71, 17)
$InputLender = GUICtrlCreateInput("", 115, 97, 281, 21)
GUICtrlSetTip(-1, "We Lend Things, Inc.")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("Loan Info:", 16, 248, 681, 201)
$Label10 = GUICtrlCreateLabel("Principal:", 27, 272, 47, 17)
$Label11 = GUICtrlCreateLabel("Write Out:", 27, 305, 52, 17)
$Label14 = GUICtrlCreateLabel("", 27, 337, 4, 4)
$InputPrincipal = GUICtrlCreateInput("", 88, 272, 153, 21)
GUICtrlSetTip(-1, "$xx,xxx.xx")
$InputWriteOut = GUICtrlCreateEdit("", 88, 304, 593, 129, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
GUICtrlSetTip(-1, "THIS MANY AND NO/100 DOLLARS (NO LINE BREAKS)")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group6 = GUICtrlCreateGroup("Trustee Info", 418, 73, 281, 161)
$Label18 = GUICtrlCreateLabel("Trustee Name:", 426, 97, 74, 17)
$InputTrustee = GUICtrlCreateInput("", 506, 97, 185, 21)
GUICtrlSetTip(-1, "I.M. Trustworthy, Jr.")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateTabItem("")
$GFLabel = GUICtrlCreateLabel("GF No:", 8, 8, 38, 17)
$CommonLabel = GUICtrlCreateLabel("Property Address:", 128, 8, 87, 17)
$CloseDateLabel = GUICtrlCreateLabel("Closing Date:", 544, 8, 67, 17)
$InputGF = GUICtrlCreateInput("", 48, 8, 73, 21)
GUICtrlSetTip(-1, "123456-RN-X")
$InputCommon = GUICtrlCreateInput("", 216, 8, 321, 21)
GUICtrlSetTip(-1, "Common address from front of file")
$InputInvoiceNo = GUICtrlCreateInput("", 72, 472, 129, 21)
$HelpButton = GUICtrlCreateButton("Help", 632, 32, 81, 25)
$LabelInvoiceNo = GUICtrlCreateLabel("Invoice No.", 8, 472, 59, 17)
$InputClosingDate = GUICtrlCreateInput("", 616, 8, 97, 21)
GUICtrlSetTip(-1, "Close date from contract")
$SaveButton = GUICtrlCreateButton("Save", 640, 472, 73, 25)
GUICtrlSetTip(-1, "Click this when you're ready to prep docs")
$InputType = GUICtrlCreateCombo("", 304, 472, 129, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "GWD|WDVL|WDMR|WDVLMR|SWD|SWDVL|SWDMR|SWDVLMR|Note & DoT|Wraparound Package")
$Label12 = GUICtrlCreateLabel("Doc Type:", 248, 472, 54, 17)
$Label13 = GUICtrlCreateLabel("Doc Cost:", 440, 472, 51, 17)
$InputCost = GUICtrlCreateInput("", 496, 472, 73, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $GF, $type, $fail[0][2], $addfail[1][2], $n = "", $invoice = 4, $sleep = 50, $aArray_invoice[12][2] = [["Field","Data"]], $buyerentitystate, $sellerentitystate, $buyerstatus, $sellerstatus, $buyer2, $seller2, $Cid, $arrayadd[1][2], $Fields[] = ["[Legal]","[Common]","[GF]","[CloseDate]","[Buyer 1]","[Buyer 2]","[Buyeradd1]","[Buyeradd2]","[Buyeradd3]","[Seller 1]","[Seller 2]","[Selleradd1]","[Selleradd2]","[Selleradd3]","[Lender]","[Lenderadd1]","[Lenderadd2]","[Lenderadd3]","[Principal]","[Write Out]","[Trustee]","[Invoice No.]","[Type]"]
hotkeyset("`", "prep")

While 1 ; What to do when buttons are pressed/forms are filled
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $HelpButton
            msgbox(-1, "Help", "Under construction!")
         Case $SaveButton
            Read()
            Parties()
            Buyers()
            Sellers()
            _arraydisplay($aArray_Base, "Saved Data")
    EndSwitch
 WEnd

 Func Read() ; Function for getting all data from input boxes
    global $aArray_Base[0][2] ; Start with clean array each time function is run
    For $n = 1 to 23 ; Make sure upper boundary is highest number in ctrl()!!
       If Guictrlread(Ctrl($n)) = NOT ("" OR 0)  Then ; Skip blank data
            $arrayadd[0][0] = $Fields[$n-1]         ; Define temporary array with data from $fields and Ctrl($n)
            $arrayadd[0][1] = Guictrlread(Ctrl($n)) ;
         If _arraysearch($aArray_Base, $arrayadd[0][0]) = NOT (-1) Then ; If [Field] is already in main array, replace data from input box, leave [Field] same
            $aArray_Base[_arraysearch($aArray_Base, $arrayadd[0][0])][1] = GuiCtrlRead(Ctrl($n))
         ElseIf @error = (6 OR 3) Then ; If Data not found or main array is empty, append new index to main array
         _arrayadd($aArray_Base, $arrayadd)
         EndIf
      EndIf
   Next
 EndFunc

 Func Ctrl($n) ; Function for passing control handles to for loops
    Select
    Case $n = 1
       $cid = $inputlegal
    Case $n = 2
       $cid = $inputcommon
    Case $n = 3
       $cid = $inputGF
    Case $n = 4
       $cid = $inputClosingDate
    Case $n = 5
       $cid = $inputBuyer1
    Case $n = 6
       $cid = $inputBuyer2
    Case $n = 7
       $cid = $inputBuyeradd1
    Case $n = 8
       $cid = $inputBuyeradd2
    Case $n = 9
       $cid = $inputBuyeradd3
    Case $n = 10
       $cid = $inputSeller1
    Case $n = 11
       $cid = $inputSeller2
    Case $n = 12
       $cid = $inputSelleradd1
    Case $n = 13
       $cid = $inputSelleradd2
    Case $n = 14
       $cid = $inputSelleradd3
    Case $n = 15
       $cid = $inputLender
    Case $n = 16
       $cid = $inputLenderadd1
    Case $n = 17
       $cid = $inputLenderadd2
    Case $n = 18
       $cid = $inputLenderadd3
    Case $n = 19
       $cid = $inputPrincipal
    Case $n = 20
       $cid = $inputWriteOut
    Case $n = 21
       $cid = $inputTrustee
    Case $n = 22
       $cid = $inputInvoiceNo
    Case $n = 23
       $cid = $inputType
    EndSelect
    Return $Cid
 EndFunc

Func Parties() ; Determine how many buyers and sellers
   local $row = _arraysearch($aArray_Base, "[Seller 2]")
  If  $row = -1 Then ; If no seller 2, seller 2 false
     global $2sellers = False
  ElseIf $aArray_Base[$row][1] = "" Then ; If seller 2 label, but not data, seller 2 false
     global $2sellers = False
  Else ; If seller 2 label and data, seller 2 true
     Global $2sellers = True
  EndIf
   local $row = _arraysearch($aArray_Base, "[Buyer 2]")
  If  $row = -1 Then
     global $2buyers = False
  ElseIf $aArray_Base[$row][1] = "" Then
     global $2buyers = False
  Else
     global $2buyers = True
  EndIf
  msgbox(-1, "", "2sellers " & $2sellers & "2buyers " & $2buyers)
EndFunc

Func Buyers()
If $2buyers = False Then ; [Buyer1&2] = [Buyer 1]
   local  $row = _arraysearch($aArray_Base, "[Buyer 1]")
   If $row = NOT -1 Then ; account for blank [Buyer 1]
   $arrayadd[0][0] = "[Buyer1&2]"
   $arrayadd[0][1] = $aArray_Base[$row][1]
   _arrayadd($aArray_Base, $arrayadd)

   $arrayadd[0][0] = "[Buyer 2]" ; Delete Buyer 2 if found
   $arrayadd[0][1] = ""
   _arrayadd($aArray_Base, $arrayadd)
   EndIf
ElseIf $2buyers = True Then ; [Buyer1&2] = [Buyer 1] and [Buyer 2]
   Local $1row = _arraysearch($aArray_Base, "[Buyer 1]")
   Local $2row = _arraysearch($aArray_Base, "[Buyer 2]")
    $arrayadd[0][0] = "[Buyer1&2]"
    $arrayadd[0][1] = "" & $aArray_Base[$1row][1] & " and " & $aArray_Base[$2row][1]
   _arrayadd($aArray_Base, $arrayadd)
EndIf
EndFunc

Func Sellers()
If $2sellers = False Then
   local $row = _arraysearch($aArray_Base, "[Seller 1]")
   msgbox(-1, "Sellers()","$row = " & $row)
   If $row = NOT -1 Then
      msgbox(-1, "Sellers()", "$row is not -1")
   $arrayadd[0][0] = "[Seller1&2]"
   msgbox(-1, "Sellers()", "$arrayadd[0][0] = " & $arrayadd[0][0])
   $arrayadd[0][1] = $aArray_Base[$row][1]
   msgbox(-1, "", "$arrayadd[0][1] = " & $arrayadd[0][1])
   _arrayadd($aArray_Base, $arrayadd)

   $arrayadd[0][0] = "[Seller 2]"
   $arrayadd[0][1] = ""
   _arrayadd($aArray_Base, $arrayadd)
   EndIf
ElseIf $2sellers = True Then
   Local $1row = _arraysearch($aArray_Base, "[Seller 1]")
   Local $2row = _arraysearch($aArray_Base, "[Seller 2]")
    $arrayadd[0][0] = "[Seller1&2]"
    $arrayadd[0][1] = "" & $aArray_Base[$1row][1] & " and " & $aArray_Base[$2row][1]
   _arrayadd($aArray_Base, $arrayadd)
   EndIf
EndFunc

Func Signatures() ; Create labels and data to fill buyer/seller fields with data entered already
EndFunc

Func Acknowledge() ; Format and fill acknowledgements based on number and type of buyers and sellers
EndFunc

Func prep()
  local $oWord = _Word_Create() ; Create Application Object
   If @error Then
      Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", "Error creating application object. Script terminated.")
   EndIf
  local $filepath = "C:\Users\Randy\Dropbox\Doc Prep\_KNDS Doc Prep Wizard (windows only)\GWD - Seller(s) People - Experiment.docx" ; Select Template to open
  local $oDoc = _word_docopen($oWord, $filepath) ; Open template
   If @error Then
      Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", "Error opening template. Script terminated.")
   EndIf
   For $i = 1 to Ubound($aArray_Base) ; Find and replace all [Fields] from main array with data
      _Word_DocFindReplace($oDoc, "" & $aArray_base[$i-1][0], "" & $aArray_Base[$i-1][1])
         If @error Then
            $addfail[0][0] = $aArray_Base[$i-1][0]
            $addfail[0][1] = $aArray_Base[$i-1][1]
            _arrayadd($fail, $addfail)
   EndIf
Next
   _ArrayDisplay($fail, "Items not replaced")
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", "Completed Find and replace. Iterations: "&$i)
   _word_docsaveas($oDoc, @HomeDrive & @HomePath & "\Dropbox\Doc Prep\_KNDS Doc Prep Wizard (windows only)\___Completed\" & guictrlread($inputgf) & " - " & guictrlread($inputtype)) ; Save working document with GF number
      If @error Then
      Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", "Error saving deed document. Script terminated." & @CRLF &  "Make sure Dropbox is installed on the PC." & @CRLF & @CRLF & "Also make sure that the following filepath exists:" & @CRLF & @CRLF & @HomeDrive & @HomePath & "\Dropbox\Doc Prep\_KNDS Doc Prep Wizard (windows only)\___Completed\")
   EndIf
   Shellexecute("" & @homedrive & @homepath & "\Dropbox\Doc Prep\_KNDS Doc Prep Wizard (windows only)\___Completed\")
   MsgBox($MB_SYSTEMMODAL, "KNDS Doc Prep Wizard", "Documents successfully prepared." & @CRLF & "Please inspect the document and the invoice for any errors, then drag and drop them to the appropriate location to save dropbox space.")
EndFunc

 

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi all,

I figured it out. Sorry for the inconvenience. I was doing this:

Func Buyers()
If $2buyers = False Then ; [Buyer1&2] = [Buyer 1]
   local  $row = _arraysearch($aArray_Base, "[Buyer 1]")
   If $row = NOT -1 Then ; account for blank [Buyer 1] ; <================= ERROR IS HERE
   $arrayadd[0][0] = "[Buyer1&2]"
   $arrayadd[0][1] = $aArray_Base[$row][1]
   _arrayadd($aArray_Base, $arrayadd)

   $arrayadd[0][0] = "[Buyer 2]" ; Delete Buyer 2 if found
   $arrayadd[0][1] = ""
   _arrayadd($aArray_Base, $arrayadd)
   EndIf
ElseIf $2buyers = True Then ; [Buyer1&2] = [Buyer 1] and [Buyer 2]
   Local $1row = _arraysearch($aArray_Base, "[Buyer 1]")
   Local $2row = _arraysearch($aArray_Base, "[Buyer 2]")
    $arrayadd[0][0] = "[Buyer1&2]"
    $arrayadd[0][1] = "" & $aArray_Base[$1row][1] & " and " & $aArray_Base[$2row][1]
   _arrayadd($aArray_Base, $arrayadd)
EndIf
EndFunc

Using $row = NOT -1 was causing problems, although I'm not sure why. Using $row <> -1 fixed everything. Thanks anyway!

-Anoig

Edited by anoig

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • anusha
      By anusha
      Hi I have jus started using auto-it . Please correct me if I'm wrong.
      I need to read data from an input in text box and search in excel file and return value in next column of matched cell on GUI.
      I have written below code but i cannot use variable which has data stored. it works only when search string is hard coded.
      Please help out.
       
      Example()
      Func Example()
      Local $GuiMain = GUICreate("EXCEL TEST", 399, 180) ;creates main GUI
      ;~ Local $idOK = GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
      Local $iWidthCell = 70
      Local $idLabel = GUICtrlCreateLabel("PART NUMBER", 10, 30, $iWidthCell,50)
      Local $RUN_1 = GUICtrlCreateButton("OK", 70, 70, 85, 25)
      Local $Input_1 = GUICtrlCreateInput("PART NUMBER", 100, 20, 120, 20)
      Local $sMenutext = GUICtrlRead($Input_1, 1)
      GUISetState(@SW_SHOW, $GuiMain)

          While 1
          $MSG = GUIGetMsg()
          Select
              Case $MSG = $GUI_EVENT_CLOSE
                  Exit
              Case $MSG = $RUN_1
                  Local $oAppl = _Excel_Open()

      Local $sFilePath1 = "D:\Anu_WorkFolder\Components.xlsx"
      Local $oWorkbook = _Excel_BookOpen($oAppl, $sFilePath1, Default, Default, True)
      Local $aResult = _Excel_RangeFind($oWorkbook, $sMenutext , Default, Default, $xlWhole)
    • Miliardsto
      By Miliardsto
      Hello.
      Drag option works only on parent window but as we can see on the parent gui is showed up child gui (on the right side with the color).
      Desired action is when we want to drag whole program we can also drag child gui and child gui will drag with parent gui.
      How to do this?
       
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> GUIRegisterMsg($WM_NCHITTEST, "_NCHITTEST") $hGUI = GUICreate("Test", 500, 500, -1, -1) $cButton_0 = GUICtrlCreateButton("Child 0", 10, 10, 80, 30) $cButton_1 = GUICtrlCreateButton("Child 1", 10, 50, 80, 30) $cButton_2 = GUICtrlCreateButton("Child 2", 10, 90, 80, 30) GUISetState(@SW_SHOW, $hGUI) ; guis Global $hChild_[3] Global $countGUI = UBound($hChild_) - 1 ;MsgBox("","",$countGUI) ; licznik dla GUI Global $gui = 0 $hChild_[0] = GUICreate("Child 0", 350, 300, 150, 0, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0xFF0000) GUISetState(@SW_SHOW, $hChild_[0]) $hChild_[1] = GUICreate("Child 1", 350, 300, 150, 0, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0x00FF00) GUISetState(@SW_HIDE, $hChild_[1]) $hChild_[2] = GUICreate("Child 2", 350, 300, 150, 0, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0x0000FF) GUISetState(@SW_HIDE, $hChild_[2]) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton_0 _All_Hide() GUISetState(@SW_SHOW, $hChild_[0]) $gui = 0 Case $cButton_1 _All_Hide() GUISetState(@SW_SHOW, $hChild_[1]) $gui = 1 Case $cButton_2 _All_Hide() GUISetState(@SW_SHOW, $hChild_[2]) $gui = 2 EndSwitch WEnd Func _All_Hide() GUISetState(@SW_HIDE, $hChild_[0]) GUISetState(@SW_HIDE, $hChild_[1]) GUISetState(@SW_HIDE, $hChild_[2]) EndFunc Func _NCHITTEST($hWnd, $uMsg, $wParam, $lParam) If $hWnd = $hGUI Then Local $aPos = WinGetPos($hWnd) If Abs(BitAND(BitShift($lParam, 16),0xFFFF)- $aPos[1]) < 500 Then Return $HTCAPTION EndIf Return $GUI_RUNDEFMSG EndFunc  
    • Dimmae
      By Dimmae
      Hello,
      at first: i'm new here, so please forgive me my mistakes, and show them to me, just that i can learn to do better in the future.
      Now to my Problem: i have an excel sheet, where i just need some columns for further actions, but i have no idea how to add single columns to a new array.
      I found the following code(the one i just added as a file) from 'water' in this forum, but i wont get how i could add multiple columns into a new array.
      The biggest problem in my situation is that i dont know the count of the rows i need for the array, i just got a fix number of rows, which is 4.
       
      Hope you can help me, and sry again for this 'unlucky illustration'.
       
      btw: how can i add code shown as code here, instead of posting it as a attached file?.
       
       
       
      autoit-select-column.au3
      defects.xlsx
    • IAMK
      By IAMK
      Hello,
       
      I have a script which uses a GUI with two buttons. It gets shown and hidden., and pressing the buttons (including their hotkeys) highlights the button, making you able to press enter the next time.
      However, I don't want that.
       
      I've tried using WinActivate() to make enter do things on another program, but the enter is still tied to the AutoIT GUI (which still has the button highlighted).
       
      Here's the important part of my code:
      $MY_GUI = GUICreate("Check.exe", 400, 300, ((@DesktopWidth / 2) - 200), -500) WinSetOnTop($MY_GUI, "", 1) ;Keeps the window on the top. $Button1 = GUICtrlCreateButton("Pass (Ctrl+P)", 40, 250, 120, 40, $WS_GROUP) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Button2 = GUICtrlCreateButton("Fail (Ctrl+F)", 240, 250, 120, 40, $WS_GROUP) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $GUIText = GUICtrlCreateLabel("", 20, 10, 360, 230) GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif") GUICtrlSetData($GUIText, Execute($stepMessage[$step])) $showGUI = "True" GUISetState(@SW_SHOW) While($showGUI = "True") $buttonPressed = GUIGetMsg() Switch $buttonPressed Case $Button1 ;Pass $pass = "True" $buttonPressed = 0 $showGUI = "False" GUISetState(@SW_HIDE) Case $Button2 ;Fail $buttonPressed = 0 $showGUI = "False" GUISetState(@SW_HIDE) While($message = "") $message = InputBox("Check.exe", "Please enter the reason the step failed." & @CRLF, "", "", 300, 200, ((@DesktopWidth / 2) - 150), -400) WEnd Return $message EndSwitch WEnd Local $pass = "False" ;Whether "Pass" or "Fail" was pressed. Local $failLog = xxxfunc($pass) ;Returns a message to log if the step failed. ##THIS CALLS THE CODE SNIPPET ABOVE## FileWrite($file, _Now() & ": Step " & $step & getStatus($pass) & "and took " & Ceiling(TimerDiff($timer) / 1000) & " seconds." & @CRLF) If($failLog <> "") Then FileWrite($file, "Logged comment: " & $failLog & @CRLF) EndIf WinActivate("[TITLE:ProgramName]") ;Hotkeys: HotKeySet("^{p}", "pressPass") HotKeySet("^{f}", "pressFail") Func pressPass() $buttonPressed = $Button1 EndFunc Func pressFail() $buttonPressed = $Button2 EndFunc  
      The GUI's button/hotkey pressing works correctly.
      The same WinActivate code works in another script of mine.
      Together, WinActivate is not take "Active" away from the GUI's last-pressed button. How do I fix this?
       
      Thank you in advance.
    • fatpig
      By fatpig
      Dear AutoIT Community.
      I am currently working on a program that will display lots of images in a scroll down GUI.
      I create the GUI based on the number of images, which works fine.
      But all images I place using GuiCtrlCreatePic above a threshold of around 32000 pixels (cant say exactly) are placed at negative locations and finally will reach 0 again
      and will then populate on top of the images placed there before.
      For $i = 1 To $Images[0] ; Get picture dimensions $hImage = _GDIPlus_ImageLoadFromFile($ImgRep & $Images[$i]) $iX = _GDIPlus_ImageGetWidth($hImage) $iY = _GDIPlus_ImageGetHeight($hImage) _GDIPlus_ImageDispose($hImage) ; Resize & place images in GUI $Pic[$i] = GUICtrlCreatePic($ImgRep & $Images[$i], $Spacer, Round($yPos, 0), $MaxImgWidth, $MaxImgWidth * ($iY / $iX)) $yPos = $yPos + $MaxImgWidth * ($iY / $iX) + $Spacer $log = $log & "|" & $yPos $currentlut = $Images[1] Next I have found a limit at 32767 pixels for some GUI elements when googling around.
      Can someone tell me how to circumvent that?
      thanks!
      cheers
      Felix