Jump to content

Recommended Posts

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Posted

My oringal code was able to select the correct sex that the $Male and $Female showed it just was not updating with the cell from $Data using my if statement. When I use your If /ElseIf it activates the dropdown box but fails to select the sex so it stop before the MouseClick instruction. We know that $Data is picking up the correct cell info. 

Should I make a break point after the ElseIF to catch if the $Data is being passed on correctly? I guess that is what the messagebox is telling us.

I have tried removing the trailing spaces from Excel and the If statement. no differance and I  have tried using number instead of Male / Female.

This is just the last step to crack before I can start importing records. Would have been a lot easier if the guy who wrote the database didnt have a bug in the "Import Records" area. I would write my own database for it which would have been quicker but I get stuck with the inbreeding coefficient formula.

Anyway. Thanks for helping, I will bang on and see if I can find where this is getting stuck.

Cheers Bruce

Posted

I just tried to send the letter of the word within the dropbox as this works manually

If $Data = "Female " Then
   Send("F")
    ;MouseClick("left",268,148,1) ; Select Female
    Sleep (500)
 ElseIf $Data = "Male " Then
    Send("M")
    ;MouseClick("left",227,130,1) ; Select Male
    Sleep (500)
EndIf

But no joy.

Posted

I  have changed the word Female to Orange both on the spreadsheet and within the If statement and it works Yah Yah so there must be another call for Female or it os formatted in excel or something along that path.

Thanks so much for your help.

It is only 1:49 Am here and I've been at this all day so I'm off to bed. Thanks again

Bruce

Posted
MouseClick("left",902,695,1) ;Select New Dog window
_WinWaitActivate("New Dog","")  ; Back to New Dog

MouseClick("left",233,101,1) ;open sex
Sleep (1000)

  $Data = ClipGet()

If StringStripWS($Data, 8) = "Orange" Then
  MouseClick("left",268,148,1) ; Select Female
Else
  MouseClick("left",227,130,1) ; Select Male
EndIf
Sleep (500)

MsgBox($Data, "Title", "This is the sex copied " & $Data & " select the OK button.",10)

 

Posted (edited)

Ahhh, found the problem.  There is a no-break-space (0xA0) at the end of the sex field.  You can see it with the snippet I provided.  Both Male and Female.

#include <Excel.au3>

Local $hWnd = WinGetHandle("New Dog")

Local $oExcel = _Excel_Open()
Local $oWorkBook = _Excel_BookOpen($oExcel, @ScriptDir & "\pedproimport2.xls")

Local $sData = _Excel_RangeRead($oWorkBook, Default, "B2") ; testing content for male
ConsoleWrite (Binary($sData) & @CRLF)
$sData = _Excel_RangeRead($oWorkBook, Default, "B3") ; now testing for female
ConsoleWrite (Binary($sData) & @CRLF)

WinActivate($hWnd) ; where $hWnd equals the pedpro window handle
WinWaitActive($hWnd)

MouseClick("left",233,101,1) ;open sex
Sleep(800)
; trim A0 char
If StringTrimRight($sData, 1) = "Female" Then ; now it is working properly :)
  ConsoleWrite ("Female Found" & @CRLF)
  MouseClick("left",268,148,1) ; Select Female
Else
  MouseClick("left",227,130,1) ; Select Male
EndIf
Sleep (500)

 

Edited by Nine
Posted (edited)

Here the framework of how you could do your xfer.  Notice I don't use clipboard, as it is not necessary.  That should work quite well.

#include <Excel.au3>

;Local $hWnd = WinGetHandle("New Dog")

Local $oExcel = _Excel_Open()
Local $oWorkBook = _Excel_BookOpen($oExcel, @ScriptDir & "\pedproimport2.xls")

;WinActivate($hWnd) ; where $hWnd equals the pedpro window handle
;WinWaitActive($hWnd)

Local $aArray, $sField

For $line = 2 To 3 ; 1919
  $aArray = _Excel_RangeRead($oWorkBook, Default, "A" & $line & ":AI" & $line)
  ;_ArrayDisplay($aArray)
  For $i = 0 To UBound($aArray, 2) - 1
    $sField = $aArray[0][$i]
    ;ConsoleWrite ($i+1 & " Field = " & Binary($sField) & @CRLF)
    If Asc(StringRight($sField, 1)) = 0xA0 Then
      $sField = StringTrimRight($sField, 1)
      ;ConsoleWrite ("Found A0 here" & @CRLF)
    EndIf
    Switch $i
      Case 0
        ; do your xfer of the pedigree
      Case 1    ; gender
        MouseClick("left", 233, 101, 1) ;open sex
        Sleep (800)
        If $sField = "Female" Then   ; now it is working properly :)
          MouseClick("left", 268, 148, 1) ; Select Female
        Else
          MouseClick("left", 227, 130, 1) ; Select Male
        EndIf
        Sleep(500)
      Case 2
        ; do your xfer of the name
        ; Case etc....rest of the field
    EndSwitch
  Next
  ; close the record here and start new record
Next

You will need to complete the transfer of each field.  I gave you just gender.  You can uncomment statements to see a bit more of what it is going on.

Edited by Nine

Create an account or sign in to comment

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

Create an account

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

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...