3 posts in this topic
Here's a cleaned up version of my code:
; Open Greatsite.com
Global $oIE = _IECreate ("http://www.greatsite.com")
; I'm logged in and on the forum page. Now to navigate categories with unknown names.
; Grab all links on page, then only dive into the ones with the text "forum_id="
; as in ?bview=forum&forum_id=108343
Global $oLinksCategoryPage = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended
;Now at the thread level. Navigate into each thread and look at timestamp
Global $oLinksOfThreads = _IELinkGetCollection($oIE)
For $oLinkThread In $oLinksOfThreads
If StringInStr($oLinkThread.href,"thread_id") Then
;Need to find instance of Posted and read text after the href.
Local $sBodyText = _IEBodyReadText($oIE)
;Find first instance of the word "Posted" and check the two words to the right of it.
Local $aArrayOfBodyText = _StringExplode($sBodyText," ",0)
;_ArrayDisplay($aArrayOfBodyText, "The body text in Array form")
;Local $iIndexOfPosted = _ArraySearch($aArrayOfBodyText,"days")
For $iIndex = 0 to ubound($aArrayOfBodyText) - 1
If StringInStr(StringLower($aArrayOfBodyText[$iIndex]), "posted") Then
;The word Posted has been found. Look for "Just A moment ago", "minutes", and "minute"
Case StringLower($aArrayOfBodyText[$iIndex +1]) = "just"
;"Just a moment ago. Grab this one.
Case Stringlower($aArrayOfBodyText[$iIndex +2]) = "minute"
;"1 minute". Grab this one
Case Stringlower($aArrayOfBodyText[$iIndex +2]) = "minutes"
;"x minutes. Grab this one
;ExitLoop ;Found the first one. I'm done.
;Need to back out to Threads in Category
;Back out to Category List
The script works fine until I hit the Next to go back to the For $oLinkThread In $oLinksOfThreads. Any line that I put after that crashes with an error. It's like the For loop is going one too many iterations and there is no object in the variable.
The requested action with this object has failed.:
If StringInStr($oLinkThread.href,"thread_id") Then
If StringInStr($oLinkThread^ ERROR
Below is an example of my code that will reproduce an issue I am having, all be it an issue that sometimes occurs and sometimes does not.
#include <WinAPI.au3> #include <IE.au3> #include <MsgBoxConstants.au3> #include <Array.au3> Call ("Project") Func Project() Local $WaitTime = 10000 ; Set the time between checks in miliseconds While 1 $hwnd = WinGetHandle("[active]") If Not @error Then ; Ensure 'WinGetHandle' worked. Local $WinClassName = _WinAPI_GetClassName($hwnd) If $WinClassName = "IEFrame" Then ; If the curent window is an IE exploere instance then... Local $Object = _IEAttach($hwnd, "embedded") If not @error Then Local $url = _IEPropertyGet($Object, 'locationurl') If not @error Then Local $Split = StringSplit($url, "/") If $Split > 2 Then ; This stops an error if the array did not have enought rows e.g no url to display form row 3. If Not $Split = "" Then ; Dont bother if no url e.g blank msgbox(0, "URL is:", $Split) EndIf EndIf EndIf EndIf EndIf EndIf Sleep($WaitTime) WEnd EndFunc The issue is from IE.au3 and the error message is attached. I am able to reproduce it is I run the scrip, load an instance of IE, then navigate to a different page such as google or something.
I have looked in the code for IE.au3 and it reference to a function “__IEControlGetObjFromHWND(ByRef $hWin)” however I am not using this function so am a little unsure why or how this error is being called or what I can do to stop it?
Any advice / help would be gratefully appreciated.
I am very new to AutoIt and scripting in general and have a question about IEFormGetObjByName. The help function says:
_IEFormGetObjByName ( ByRef $oObject, $sName [, $iIndex = 0] )
But how do I find what to enter for $sName? In the example below, it says that it can be found by viewing the HTML source. So I went to the google home page, clicked Ctrl U to view the source, and cant figure out how they determined that the $sName is 'gbqf'. Can someone explain this process to me? Thanks in advance!
; Get a reference to a specific form by name. In this case, submit a query
; to the Google search engine. Note that the names of the form and form
; elements can be found by viewing the page HTML source
Local $oIE = _IECreate("http://www.google.com")
Local $oForm = _IEFormGetObjByName($oIE, "gbqf")
Local $oQuery = _IEFormElementGetObjByName($oForm, "q")
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
First of all sorry for my bad english.
I'm trying to build a automated program/autoit that controls a web app.
I created the script using mouseclick() , but i don't want the web browser to be visible.
I tried ControlClick() , but the web app uses flash and the buttons/items to be clicked do not have an ID.
I searched and visited a lott of autoit post and pages (even in german ) , but could not find a way or get it to work.
Any help is welcome!!!
I have been experiment for months trying to find a way to be able to like script the find button to find some text and click on that text or something nearby.
Is this possible? When the search hilites the text of course this is not where the cursor is so you cannot command a click at that point. I can get the coordinates of any point and go there and click... but I cannot find the coordinates of a piece of text i have searched up and click that..