Jump to content

Posting to website


Recommended Posts

#include <Excel.au3>
#include <IE.au3> 

_ExcelBookOpen("C:\Users\Corey\Dropbox\Allison & Corey\2012Values2.1.xlsm")

Local $oIE = _IECreate("http://football.fantasysports.yahoo.com/f1/28910/setkeepercosts")

Local $o_Form = _IEGetObjByName($oIE, "setcosts")
$o_cost = _IEFormElementGetObjByName($o_Form, "24823")
_IEFormElementSetValue($o_cost, "222")
_IEFormSubmit($o_Form)

$OTable=_IETableGetCollection($OIE,0)
$OTableData = _IETableWriteToArray($oTable) 

Complete newb here so bare with me... Im trying to create a script that will read an excel file and post to an appropriate box on the website. I have figured out how to post to the website. My issue is how do i figure out through autoit which is the appropriate box? When i check the coding of the web page the text boxes are just assigned random number for the id. i basically have to check the html coding of the element to the left of the box, see what the text in it being displayed is, match it to the correct cell in a column in excel then post the value of the column to the right into the text box on the website directly to the right of the element originally checked.... IS this even possible? here is what i have so far

Link to comment
Share on other sites

#include <Excel.au3>
#include <IE.au3> 
#include <Array.au3>

Dim $var1 

_ExcelBookOpen("C:\Users\Corey\Documents\fantasyvalues.xls")
Local $Oexcel = _ExcelBookOpen("C:\Users\Corey\Documents\fantasyvalues.xlsx")

$Oexcel.cells.find("Drew Brees").Select
$Oexcel.activecell.offset(0,1).Select
$var1=$Oexcel.activecell.value
MsgBox(0,"Test",$var1)

$oIE = _IECreate("http://football.fantasysports.yahoo.com/f1/28910/setkeepercosts")

;Local $o_Form = _IEGetObjByName($oIE, "setcosts")
;$o_cost = _IEFormElementGetObjByName($o_Form, "24823")
;_IEFormElementSetValue($o_cost, "222")
;_IEFormSubmit($o_Form)

i figured i would add the part i already know.... "Drew Brees" is an example of a text i would find on the web and i would look up his name in the excel sheet as the coding already does. then once i have a value from the sheet i in turn need to enter it into the box just to the right of the name. They are in the same TR tag...

autoit.png

Link to comment
Share on other sites

Welcome to AutoIt and the forum!

Looks like a game you are trying to automate.

Please read the forum rules and you will see that game automation isn't allowed here.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Welcome to AutoIt and the forum!

Looks like a game you are trying to automate.

Please read the forum rules and you will see that game automation isn't allowed here.

 

Its not automating a game. It is for fantasy football, and yearly i have to enter the prices of each player online prior to the draft. there are 400 players and this would take hours. So i am just automating the setting up of the league? I don't think that is considered game automating is it?

Link to comment
Share on other sites

#include <Excel.au3>
#include <IE.au3> 
#include <Array.au3>








Dim $var1
Dim $sHTML
Dim $sSearchText
Dim $oTable
Dim $oTR
Dim $oTD
Dim $sTblCont
Dim $oLink

_ExcelBookOpen("C:\Users\Corey\Documents\fantasyvalues.xls")
Local $Oexcel = _ExcelBookOpen("C:\Users\Corey\Documents\fantasyvalues.xlsx")

$sSearchText="Colin Kaepernick"

$Oexcel.cells.find($sSearchText).Select
$Oexcel.activecell.offset(0,1).Select
$iPrice=$Oexcel.activecell.value
;MsgBox(0,"Test",$SSearchText&" "&$iPrice)

$oIE = _IECreate("http://football.fantasysports.yahoo.com/f1/28910/setkeepercosts")

;Local $o_Form = _IEGetObjByName($oIE, "setcosts")
;$o_cost = _IEFormElementGetObjByName($o_Form, "24823")
;_IEFormElementSetValue($o_cost, "222")
;_IEFormSubmit($o_Form)


$oTable = _IETableGetCollection($oIE, 1) ; select first table, index 0
$oTR = _IETagnameGetCollection($oTable, "TR")
$oTRs = _IETagnameGetCollection($oTable, "TR")
$oTD = _IETagnameGetCollection($oTR, "TD")
$oTDs = _IETagnameGetCollection($oTR, "TD")

For $oTR In $oTRs
   
    
    For $oTD in $oTDs
       $sTblCont = _IEPropertyGet($oTD, "innertext")
       If $sTblCont=$sSearchText Then 
          $var1=1 
          MsgBox(0,"",$sTblCont&" "&$sSearchText)
          $oInput = _IETagnameGetCollection($oTD, "Input")
          _IEFormElementSetValue($oInput, "666")
       Else
          $var1=0
       EndIf
        
    Next
    
Next

this is where i am at right now. Ready to band my head against a wall... :x 

Link to comment
Share on other sites

;Globals
Dim $var1
Dim $sHTML
Dim $sSearchText
Dim $oTable
Dim $oTR
Dim $oTD
Dim $sTblCont
Dim $oLink


;$Oexcel =_ExcelBookOpen("C:\Users\Corey\Documents\fantasyvalues.xls")
_ExcelBookOpen(@DesktopDir & "\fantasyvalues.xlsx")
$oExcel = ObjGet("", "Excel.Application")
That gets me past the $oExcel error & on to the $oIE error

Beyond that I will be of little use to you on this one.

Edited by lorenkinzel
Link to comment
Share on other sites

  • Moderators

Your question is too generalized for us not being able to test the code ourselves. Narrow your example down to the section of code that is not working and then provide the information necessary to troubleshoot it. Example; error messages (_IEErrorHandlerRegister), html source, DOM structure (F12 or DebugBar).

Link to comment
Share on other sites

think i figured it out! Autoit is an amazing thing. Funny how such simple coding can take hours when your learning  >_<  haha lots of fun though. here is the final code for future reference

#include <Excel.au3>
#include <IE.au3> 
#include <Array.au3>








Dim $var1 = 0
Dim $sHTML
Dim $sPlayer
Dim $oTable
Dim $oTR
Dim $oTD
Dim $sTblCont
Dim $oLink
Dim $Done=0

_ExcelBookOpen("C:\Users\Corey\Documents\fantasyvalues.xls")
Local $oExcel = _ExcelBookOpen("C:\Users\Corey\Documents\fantasyvalues.xlsx")
$oIE = _IECreate("http://football.fantasysports.yahoo.com/f1/28910/setkeepercosts")





Local $o_Form = _IEGetObjByName($oIE, "setcosts")
;$o_cost = _IEFormElementGetObjByName($o_Form, "24823")



$oTable = _IETableGetCollection($oIE, 1) ; select first table, index 0
$oTRs = _IETagnameGetCollection($oTable, "TR") 
 
 For $oTR In $oTRs
   $oTDs = _IETagnameGetCollection($oTR, "TD")
    
    For $oTD in $oTDs
       $sCell = _IEPropertyGet($oTD, "innertext")
       
       If $sCell == 0 Then
          ExitLoop
       EndIf
       
       $oExcel.cells.find($sCell).Select
       $oExcel.activecell.offset(0,1).Select
       $iPrice= $oExcel.activecell.value
       
          $oInputs = _IETagnameGetCollection($oTR, "Input")
          
          For $oInput In $oInputs
             $var=$oInput.name
             $oText=_IEFormElementGetObjByName($o_Form, $var)
             _IEFormElementSetValue($oText, $iPrice)
             ExitLoop
             
         Next
   Next    
Next
Link to comment
Share on other sites

BTW: Don't use "Dim" as it is deprecated, use "Global".

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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