Sign in to follow this  
Followers 0
Jfish

Converting _IETableWriteToArray to _FFTableWriteToArray

13 posts in this topic

I am embarrassed to ask this but it is not obvious to me after searching around the forum :> .  I am trying to convert a working IE script to read shipping information from a table in our shopping cart solution to FF. 

This is the working IE version:

Local $oTable = _IETableGetCollection($oIE,20)
Local $3dcartShipToTable = _IETableWriteToArray($oTable)

I grabbed the ff.au3 UDF and found the thread to replace the "/" in the code.  I can start it up etc.  Then I found the thread to grab the MozRepl plugin (which I did).  However, this code:

_ffStart("http://pacebands.3dcartstores.com/admin")
MsgBox("","","hold the phone")
$ffarray=_FFTableWriteToArray(11)
_ArrayDisplay($ffarray)

Results in this error:

__FFStartProcess: ""C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -new-window "http://pacebands.3dcartstores.com/admin"  "-repl 4242 "
_FFConnect: OS: WIN_81 WIN32_NT 9600 
_FFConnect: AutoIt: 3.3.12.0
_FFConnect: FF.au3: 0.6.0.1b-10
_FFConnect: IP: 127.0.0.1
_FFConnect: Port:   4242
_FFConnect: Delay:  2ms
_FFConnect ==> Timeout: TCPConnect Error: 10061
_FFConnect ==> General Error: Timeout: Can not connect to FireFox/MozRepl on: 127.0.0.1:4242
__FFSend ==> Socket Error
_FFCmd ==> Error return value
_FFTableWriteToArray ==> Invalid value: (INT) $vTable: 11

I am sure this is simple and I am doing something wrong but I am getting a bit lost in all the ff.au3 threads.  Can anyone set me straight?


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites



Make sure that you have MozRepl started (look under Tools > MozRepl menu). You should make sure that "Activate on startup" is selected so that you don't run into this issue every time.

Share this post


Link to post
Share on other sites

Thanks @Danp2 - I found tools with "ALT + T" and did that.  That error is now resolved.  Now I am just trying to find that particular table.  I will play with it a bit more and report back...


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

Okay, another dumb question  ...

I can't get the table function to work.  I looked in the UDF and here is what I came up with:

; this works
Local $oTable = _IETableGetCollection($oIE,20)
Local $3dcartShipToTable = _IETableWriteToArray($oTable)
; is the syntax in ff for the above this? b/c it does not work
$ffarray=_FFTableWriteToArray(19)

Do I need to get the table object first and pass that?  The UDF suggests that the first parameter can be the index value if $sMode is defaulted to index (at least that is how I read it).  It also looks like you don't need to "attach" to the instance of FF like you do in IE.  If that is not the case, please let me know.  Here is the error I get:

__FFSend ==> Socket Error
_FFCmd ==> Error return value
_FFTableWriteToArray ==> Invalid value: (INT) $vTable: 20

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

It's telling you that it doesn't detect that many tables on the current page. The UDF needs to know which tab you intend to interact with, so you will need to establish that first (see _FFWindowSelect and _FFTabSetSelected) and then call _FFTableWriteToArray.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thanks for hanging in there with me on this one - I think the FF UDF has a learning curve (or it could just be me).  Either way, I have another question ...

If the tab I am interested in is the only open tab I should be able to do this, correct?:

_FFWindowSelect()
_FFTabSetSelected()
$ffarray=_FFTableWriteToArray(20)
_ArrayDisplay($ffarray)

***EDIT*** I added

_FFConnect()

It now finds the pages etc.  However, it can't seem to find the table still ...

_FFConnect: OS: WIN_81 WIN32_NT 9600 
_FFConnect: AutoIt: 3.3.12.0
_FFConnect: FF.au3: 0.6.0.1b-10
_FFConnect: IP: 127.0.0.1
_FFConnect: Port:   4242
_FFConnect: Delay:  2ms
_FFConnect: Socket:     632
_FFConnect: Browser:    Mozilla/5.0 (Windows NT 6.3; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0
__FFSendJavaScripts: Sending functions to FireFox .......... done
__FFSend: try{repl.enter(Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow("navigator:browser"))}catch(e){'_FFCmd_Err';};
__FFRecv: [object ChromeWindow] - {0: {...}, 1: {...}, 2: {...}, 3: {...}, 4: {...}, 5: {...}, 6: {...}, ...}
__FFSend: try{FFau3.tmp=document.title;document.title='FFAU31143185670'}catch(e){'_FFCmd_Err';};
__FFRecv: FFAU31143185670
__FFSend: try{document.title=FFau3.tmp}catch(e){'_FFCmd_Err';};
__FFRecv: 3DCart v6.4.1 Store Manager - Mozilla Firefox
_FFWindowGetHandle: 0x0052103A
__FFSend: try{gBrowser.tabContainer.selectedIndex = 0}catch(e){'_FFCmd_Err';};
__FFRecv: 0
__FFSend: FFau3.WCD=window.content.top.document;
__FFRecv: [object XrayWrapper [object HTMLDocument]] - {location: {...}, home: {...}, stats: {...}, crm: {...}, search1: {...}, view-store: {...}, email: {...}, ...}
[object XrayWrapper [object HTMLDocument]] - {location: {...}, home: {...}, stats: {...}, crm: {...}, search1: {...}, view-store: {...}, email: {...}, ...}
_FFTableWriteToArray ==> General Error: //table[20] not found.
Edited by Jfish

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

Does the site use frames? If so, take a look at the online help entry for _FFFrameEnter.

Share this post


Link to post
Share on other sites

Okay, I have more info.  First, I was able to get some arrays back for tables.  However, not the one I want.  I also noticed that the index does not seem to follow the same rules as IE so my assumption I could use  the same table number seems wrong.  That said, this is the exact table I am after:

<table width="100%" cellpadding="2" cellspacing="0" border="0" style="padding-top:4px;padding-bottom:4px;" class="tablenooutline" id="Table13">
            <tr>
              <td class="searchheader">Name:</td>
              <td>Doe, Jane</td>
            </tr>
            <tr>
              <td class="searchheader">Company:</td>
              <td></td>
            </tr>
            <tr>
              <td class="searchheader" valign="top">Address:</td>
              <td>555 Main Street<!--START: shipAddress2--><br>
                APYT #1<!--END: shipAddress2--> 
                <br>
                Boston, MA, 02110, US </td>
            </tr>
            <tr>
              <td class="searchheader">Phone:</td>
              <td>6175551212</td>
            </tr>
            <!--START: addressType--><!--END: addressType-->
            <tr>
              <td class="searchheader">Method:</td>
              <td > Free Shipping 
                <!--START: editShippingMethod--><!--END: editShippingMethod--></td>
            </tr>
          </table>

The code I tried to use to get at it was:

_FFConnect()
_FFWindowSelect()
_FFTabSetSelected()
$ffarray=_FFTableWriteToArray("Table13","id")
_ArrayDisplay($ffarray)

I get this error when searching on that table:

_FFTableWriteToArray ==> General Error: //table[@id='Table13'] not found.

I do not believe frames are in use.


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

Can you post a file containing the complete HTML page?

Share this post


Link to post
Share on other sites

#include <FF.au3>
#include <Array.au3>

Local $url = 'orderpage.html'

_FFConnect(Default, Default, 3000)

_FFWindowSelect($url, 'href', False)
_FFTabSetSelected($url, 'href')

$ffarray=_FFTableWriteToArray("Table13","id")
_ArrayDisplay($ffarray)

With the above code, the array would get created but it's contents were incorrect. I found what appears to be a bug in _FFTableWriteToArray. Find the following line in FF.au3:

$aTable[$j][$i] = $aRows[$i + 1]

and change it to:

$aTable[$j][$i] = $aRows[$j + 1]
1 person likes this

Share this post


Link to post
Share on other sites

You're welcome

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

  • Similar Content

    • ripdad
      By ripdad
      WSA_NBTCP.au3  (Windows Sockets API - Non-Blocking Transmission Control Protocol)
      Version: 1.00
      Type: UDF
      This is an accumulation of WSA code from many sources and modified to suit myself.
      These functions have been thoroughly tested using a Local Proxy Server, which
      is about the most strenuous test you can use.
      Includes my rendition of how a TCPRecv Timeout should work. Also includes a
      timewait/timeout using Select for TCP Send, which works great for that function.
      You will need a loop to use _WSA_TCPRecv(). An example will be forthcoming in a second post.
      Functions:
      #CURRENT_USER_FUNCTIONS
      _WSA_Cleanup
      _WSA_FormatMessage
      _WSA_GetLastError
      _WSA_TCPAccept
      _WSA_TCPCloseSocket
      _WSA_TCPConnect
      _WSA_TCPListen
      _WSA_TCPRecv
      _WSA_TCPSend

      #INTERNAL_FUNCTIONS
      __TimeoutManager
      __TimeoutReset

      #EXTRA_FUNCTIONS
      _WSA_GetAddrInfo
      _WSA_GetHostByAddr
      _WSAAsyncGetHostByName
      _WSAAsyncGetHostByName_Callback
      _WSA_GetNameInfo
       
      Requirements:
      - AutoIt Versions: 3.3.8.1 thru 3.3.15.0 (32Bit only).
      - TCPStartup() at beginning of script on startup.
      - TCPShutDown() and _WSA_Cleanup() on exit.
      Download UDF: WSA_NBTCP.au3
       
    • Tippex
      By Tippex
      I have a problem trying to use _IEAttach to recover control after a Windows Explorer reset (e.g. on Windows 7), since all the 
      InternetExplorer.Application objects appear to be destroyed by this event. An example of this is when a PC has some kind of fault causing a pop-up error message "Windows Explorer has stopped working". I can simulate this event by using Windows Task Manager to end the Explorer.exe process then to file, new task (run...) Explorer.exe
      After this event, _IEAttach gives an @error of: 
      7 ($_IEStatus_NoMatch) - No Match
      However, using WinList() followed by WinGetText() I can recover the URL for an IE session that has lost its 
      InternetExplorer.Application object which could be used to _IECreate a new session (the $iTryAttach fails) and WinKill() the original session but the result is a if a refresh had been done (any form entries are lost) . Unfortunately form entries do not appear as text or hidden text to Windows so I'm looking for the best way to read the contents of an Internet Explorer screen (even if just text without structure). 
      When there is no InternetExplorer.Application object (because of some Windows fault) but still with an Internet Explorer session running, I tried to read its contents by a "Select All" & "Copy to Clipboard" but its form entries are blanked and combo boxes choices are all displayed with no way of finding out which ones were selected.
      Local $ClipBoardSave = _ClipBoard_GetData() ;not ClipGet() which is text only ClipPut("") ;Clear User's Clipboard Local $sText = "" Local $hWnd = WinActivate("Window Title", "") If IsHWnd($hWnd) Then Local $bStatusCtrlSend = ControlSend("Window Title", "", "", "^a^c") If $bStatusCtrlSend Then Local $bStatusCtrlClick = ControlClick("Window Title", "", "") If $bStatusCtrlClick Then $sText = ClipGet() _ClipBoard_SetData($ClipBoardSave) ;not ClipPut($ClipBoardSave) which is text only  
      Is  there a solution to this please?
    • tarretarretarre
      By tarretarretarre
      AutoIt-SocketIo
      Yep yep, this is pretty much an attempt to port the existing project's concept https://socket.io/ to AutoIt's Codebase. So i will not go in to so much detail.
      This is how the communication is done http://i.imgur.com/0mMfsBD.png Each client is isolated to the server http://i.imgur.com/rVO2LFb.png Features
      Easy API VarType Translation (Example: If the server sends an int, the client will receive an int and vice versa) Fully featured examples Data encryption (Using Autoit's UDF Crypt.au3) Limitations / Drawbacks
      It is not possible to Broadcast/Emit objects Only 1D-arrays are allowed to be Broadcasted/Emitted (2D arrays will probably never be supported) Changelog
      Version 1.5.0 (This update DOES NOT break scripts)
      Added AutoIt like docs under Docs\. The docs are generated so its a 1 to 1 reflection of the UDF headers. Print of documentation Added a production ready server example. Added a new method: _Io_DevDebug which will display useful information when debugging. Added a new method: _Io_SetMaxRecvPackageSize which defaults to whatever _Io_setRecvPackageSize is set to. Added a new method: _Io_setOnPrefix which defaults to _On_ Added a new default client & server event called flood. Flood occurs when exceeding the $__g_io_nMaxPacketSize. $__g_io_nMaxPacketSize is set by _Io_SetMaxRecvPackageSize Fixed the 16 parameter limit when sending data with _Io_Emit, _Io_Broadcast, _Io_BroadcastToAll and _Io_BroadcastToRoom. This works on the same premise that AutoIt's Call Does Fixed a TRUNCATION problem when receiving packages which could cause crashes! Fixed a programming error which caused $__g_ionPacketSize to reset to default 4096 if _Io_Connect or _Io_listenwere called after _Io_setRecvPackageSize Fixed _Io_setEventPreScript and _Io_setEventPostScript They didnt work. Lol. Changed how events are fired so the client cannot crash the server by sending the wrong number of parameters (This also allows for optional parameters on callbacks) Changed _Io_On. The second parameter $fCallback can now be set to null. Doing this, the function assumes that the callback is: _On_<eventName>.  
      Changelog History
      Api methods
      Please see the docs provided
      Default events
      Server events
      connection Client events
      banned Server and Client events
      disconnect flood View source on github
       
      Autoit-Socket-IO-1.0.0.zip (OLD!)
      Autoit-Socket-IO-1.1.0.zip (OLD)
      Autoit-Socket-IO-1.3.0.zip (OLD)
      Autoit-Socket-IO-1.4.0.zip (OLD)
      Autoit-Socket-IO-1.5.0.zip (NEWEST 2017-12-20)
    • mattia100
      By mattia100
      HI!
      1) I want to create a FF web page in background... i want to say a web page that can't be seen in the application bar  but only in Windows Task Manager... 
      maybe using  __FFStartProcess? in fact i tried to use it but the parameter "hide" only can minimize the page, but not put it in background... 
      2) After creating this hide page, i would to open a macro of the iMacros addon, always all in hide mode...
      it is possible to do it?
      anybody can help me?
      Thanks!!
    • BlazerV60
      By BlazerV60
      Hello all,
      I've written the code below which launches chrome in incognito mode and then proceeds to go to the autoit website.
      From my understanding, the Run() command is also supposed to output the PID number related to the application that got launched from the Run command.
      However when I run the below lines, it outputs a PID number that is different from the newly launched chrome browser's PID number, does anyone know why and possibly explain how I could retrieve the accurate PID number associated with the newly launched browser?
      Global $iPid = Run(@ComSpec & ' /c start chrome.exe https://www.autoitscript.com/forum/ -incognito' ,"", "") msgbox(0,"",$iPid) Thank you,
      Brian