Sign in to follow this  
Followers 0
AltTab

Siebel Service CRM scraping

1 post in this topic

#1 ·  Posted (edited)

An example of capturing the left most column in a CRM like Siebel. The Edit instances will not normally be the same number so i used the X axis to find the data from the left column. That value for the X axis does not need to be static, having a dynamic number is how you would want to go if you were also looking to capture more than just the left column. And each CRM is different, this is what worked for me.

#include <MsgBoxConstants.au3>

 $sAppTitle = "Siebel Service"
Local $hWnd = WinWait($sAppTitle, "", 10)
If IsHWnd($hWnd) Then

    Local $sClassList = WinGetClassList($hWnd)
    Local $sSplitClass = StringSplit(StringTrimRight($sClassList, 1), @LF)
    Local Const $iMax = 18

   ; NOTE: We have added the count in the first element
    Local $arr[$iMax] = [0] ; Initiate the array and place a counter in the first element.
    Global $aSiebelLColumn[$iMax] = [0] ; Initiate the array and place a counter in the first element.
    Local $nCount = 1
    Local $trigger = 0
    Global $triggermax = 4
    For $i = 0 to UBound($sSplitClass) - 1
         If $sSplitClass[$i] = "Edit" Then
            If UBound($arr) = $nCount Then
              ; Resize the array when $i is equal to the element count in the array to prevent subscript error
              ReDim $arr[$arr[0] + $iMax]
            EndIf

             $arr[$nCount] = "Edit" & $nCount ; safely add data to new index element
             $aPos = ControlGetPos($hWnd, "", "Edit" & $nCount)
             $sTxt = ControlGetText($hWnd, "", "Edit" & $nCount)
             ConsoleWrite($arr[$nCount]& " " & $aPos[0] & " " & $sTxt &  @LF)
             $arr[0] = $nCount ; update the index count for future reference
             $nCount += 1
         EndIf
      Next
   For $iCount = UBound($arr) - 1 To 1 Step - 1
      $aPos = ControlGetPos($hWnd, "", $arr[$iCount])
      If $aPos[0] = 21 then
          $sTxt = ControlGetText($hWnd, "", $arr[$iCount])
         If $trigger = 0 AND $sTxt <> '' then $trigger = 1
         If $trigger > 0 AND $trigger <= $triggermax Then
             if $trigger = 3 Then
                ;msgbox(0,"",$sTxt)
                If StringInStr($sTxt,"-")> 0 Then
                   $triggermax = 24
                Else
                  $triggermax = 18
               EndIf
             EndIf
             ;ConsoleWrite($arr[$iCount]& " txt= """ & $sTxt &"""" & @LF)
             If UBound($aSiebelLColumn) = $trigger Then
              ReDim $aSiebelLColumn[$aSiebelLColumn[0] + $iMax]
            EndIf

             $aSiebelLColumn[$trigger] = $sTxt ; safely add data to new index element
            ; ConsoleWrite($arr[$nCount]& @LF)
             $aSiebelLColumn[0] = $trigger ; update the index count for future reference
             $trigger += 1
          EndIf
      EndIf
   Next

   If $triggermax = 18 Then
      Local $custaccountno = $aSiebelLColumn[3]
      Local $accountname = $aSiebelLColumn[6]
      Local $fullname = $aSiebelLColumn[10] & " " & $aSiebelLColumn[11]
      Local $phone = $aSiebelLColumn[12]
      Local $email = $aSiebelLColumn[13]
      Local $addr1 = $aSiebelLColumn[14]
      Local $addr2 = $aSiebelLColumn[15]
      Local $city = $aSiebelLColumn[16]
      Local $state = $aSiebelLColumn[17]
      Local $zip = StringMid($aSiebelLColumn[18],1,5)
   Else ; 24
      Local $custaccountno = $aSiebelLColumn[4]
      Local $accountname = $aSiebelLColumn[9]
      Local $fullname = $aSiebelLColumn[16] & " " & $aSiebelLColumn[17]
      Local $phone = $aSiebelLColumn[18]
      Local $email = $aSiebelLColumn[19]
      Local $addr1 = $aSiebelLColumn[20]
      Local $addr2 = $aSiebelLColumn[21]
      Local $city = $aSiebelLColumn[22]
      Local $state = $aSiebelLColumn[23]
      Local $zip = StringMid($aSiebelLColumn[24],1,5)
   EndIf
Else
   MsgBox(0,"Error","Siebel not online")
EndIf

Its can happen that a error subscript dimension range exceeded or some values could be blank if the Edit boxes have not been seen yet. But that error is if you just launched the CRM, and have not scrolled to see the all the edit boxes and having some values blank does not always happen if you have not seen the complete window.

Edited by AltTab

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
Sign in to follow this  
Followers 0