Sign in to follow this  
Followers 0
Docfxit

How to paste name and address into Fedex web page

2 posts in this topic

#1 ·  Posted (edited)

I'd like to find out how to paste variables into a Fedex web page. What I have done so far is to create a script to copy the name and address from a software package called Anytime Organizer and then it will login to the Fedex web page to send a package. What I would like to figure out is how to paste the variables into the proper fields on the Fedex web page.

#include <IE.au3>
 
$Url = 'http://fedex.com/us/'
$User = 'User'
$Pwd = 'password'
 
; Copy Name & Address from Anytime Organizer
 
WinActivate("Address Details")
WinWaitActive("Address Details")
Send("^c") ;Copy selected text.
$FirstName = ClipGet() ;Retrieves text from clipboard.
Send("{TAB}"); Next field
Send("^c")
$LastName = ClipGet()
Send("{TAB}{TAB}{TAB}")
Send("^c")
$Address = ClipGet()
Send("{TAB}{TAB}")
Send("^c")
$City = ClipGet()
Send("{TAB}")
Send("^c")
$State = ClipGet()
Send("{TAB}")
Send("^c")
$Zip = ClipGet()
 
; Start Internet Explorer & Login to Fedex
$test = _IEAutoLogin($Url, $User, $Pwd)
 
;Paste Name & Address into Fedex Web page
;Paste $FirstName $LastName  into Name field
;Paste $Address           into Address field
 
 
Func _IEAutoLogin($sUrl, $sUsername, $sPwd)
;funkey 09.09.09
$oIE = _IECreate($sUrl)
_IEErrorNotify(False)
_IEErrorHandlerRegister()
$oForms = _IEFormGetCollection($oIE)
If @error Then
  Return SetError(1, _IEErrorHandlerDeRegister(), $oIE) ;'no forms --> no login'
Else
  $Index = 0
  For $oForm In $oForms
   $oFormElements = _IEFormElementGetCollection($oForm)
   If IsObj($oFormElements) Then
    $IndexElement = 0
    For $oElement In $oFormElements
     If $oElement.Type = 'password' Then
      $oPwd = _IEFormElementGetObjByName($oForm, $oElement.Name)
      _IEFormElementSetValue($oPwd, $sPwd)
      For $i = $IndexElement - 1 To 0 Step -1
       $oUser = _IEFormElementGetCollection($oForm, $i)
       If $oUser.Type = 'text' Then
        _IEFormElementSetValue($oUser, $sUsername)
        ExitLoop
       EndIf
      Next
      If $oForm.action <> "0" And Not StringInStr($oForm.action, '.php') Then  ;submit
       _IEFormSubmit($oForm, 0)
       _IELoadWait($oIE)
      Else  ;click
       For $i = $IndexElement + 1 To $IndexElement + 10 ;check the next 10 elements
        $oButton = _IEFormElementGetCollection($oForm, $i)
        If $oButton.Type = 'submit' Then
         _IEAction($oButton, "click")
         ExitLoop
        EndIf
       Next
      EndIf
      Return SetExtended(_IEErrorHandlerDeRegister(), $oIE)
     EndIf
     $IndexElement += 1
    Next
   EndIf
   $Index += 1
  Next
EndIf
Return SetError(2, _IEErrorHandlerDeRegister(), $oIE) ;no password-field found
EndFunc   ;==>_IEAutoLogin

Thanks,

Docfxit

PS: I'm not sure but I think these are the fields I need to fill:

element name: toData.addressData.companyName value:Select or enter

element name: toData.addressData.contactName value:Select or enter

element name: toData.addressData.addressLine1 value:0

element name: toData.addressData.addressLine2 value:0

element name: toData.addressData.city value:0

element name: toData.addressData.stateProvinceCode value:empty

element name: toData.addressData.zipPostalCode value:0

Edited by docfxit

Share this post


Link to post
Share on other sites



Look at the IE Management UDF library in the helpfile and search this forum. You'll likely need _IECreate, _IEFormGetObjByName, _IEFormElementGetObjByName and _IEFormElementSetValue.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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