Jump to content
Sign in to follow this  
SueB

script pausing

Recommended Posts

I am a total newbie, having been working with AutoIt for only three days, so excuse me if this should be obvious. My ultimate goal is to automate copying fund reports from a proprietary library database to web pages so faculty can see their budget status. I'm doing it in baby steps and long story short I've got this much to work so far (Since the web reports I am copying are passworded I am choosing to start assuming the person running the script has already logged in and brought up the books/media page.)

CODE

#include <IE.au3>

Opt("TrayIconDebug",1)

$oIE = _IEAttach ("Books/Media 2007/2008")

$oFrame = _IEFrameGetObjByName ($oIE, "data")

_IELinkClickByText ($oFrame, "AFRICAN-AMERICAN ")

$oDept= _IEAttach ("AFRICAN-AMERICAN")

$oFund= _IEFrameGetObjByName ($oDept, "data")

_IEAction ($oDept, "back") ; works, but only after 5 minutes.

Exit

It works that is, after five minutes. At first it seemed to just be sitting at the African-American page, not executing the command to go back. I noticed the script icon in the system tray with the "script paused" checked. That was why I added the Exit, thinking I had the "back" line wrong and the script was just sitting there.

After I found the hint to use the TrayIconDebug line and inserted it I discovered it is IE.au3 which is paused. It is pausing on line 517 sleep(100). This is in the _IELoadWait function, which confused me at first since I don't call it but I see that _IELinkClickByText does call it so I am assuming that is why the script is pausing. I decided to just wait to see if that icon eventually went away and indeed it does, and the script does correctly go back so at least I know my coding is correct.

Is there a way to not have to wait the five minutes? I have over 20 funds I need to eventually copy so I really don't want to have to wait for each.

Now that I know the "back" works I can try the "saveas". Then my idea is I can make some kind of array or call a file containing the names so I can loop through all the department names without having to manually code each. Even if that proves unfeasible at least I am learning something about AutoIt.

Edited by SueB

Share this post


Link to post
Share on other sites

From the help file:

_IELinkClickByText

--------------------------------------------------------------------------------

Simulate a mouse click on a link with text sub-string matching the string provided.

#include <IE.au3>

_IELinkClickByText ( ByRef $o_object, $s_linkText [, $i_index = 0], $f_wait = 1]] )

Parameters

$o_object Object variable of an InternetExplorer.Application, Window or Frame object

$s_linkText Text displayed on the web page for the desired link to click

$i_index Optional: If the link text occurs more than once, specify which instance you want by 0-based index

$f_wait Optional: specifies whether to wait for page to load before returning

0 = Return immediately, not waiting for page to load

1 = (Default) Wait for page load to complete before returning

:)

P.S. It's not "waiting 5 minutes", it's waiting for the page to finish loading. Keep in mind that if you set the f_wait option to 0, you better have some other way of knowing when the page is ready for you.

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thanks for the suggestion. I'm not understanding what "before returning" means apparently. I think I originally thought it meant "before clicking", in other words 'wait for the whole page to load before clicking the link I'm asking you to click'. It seems you are saying it is giving one the opportunity to say how long to stay on the page resulting from the click before returning to the original page. The default is return after the resulting page fully loads but you have the option of returning immediately. That doesn't seem right, since you would also want to be able to stay on the resulting page.

So assuming it is actually saying in effect "if there is a return (back) command, wait this long before executing", it still doesn't seem to be obeying it. I changed the line to

_IELinkClickByText ($oFrame, "AFRICAN-AMERICAN ", 0, 1)

and get the same approximately five minute waiting period where the system tray icon shows the script is paused at line 517 and then line 569 of IE.au3.

I assume since I am specifying the $f_wait parameter I also need to put in a placeholder for the $i_index parameter? Since there is only one AFRICAN-AMERICAN link on the page I put in 0. I did try just _IELinkClickByText ($oFrame, "AFRICAN-AMERICAN ", 1) and it seemed to sit at the original page and never even click on the AFRICAN-AMERICAN LINK. I assumed that was because it was thinking that was the $i_index parameter and there isn't a second instance of the link. If it was actually seeing that as the $f_wait parameter and clicking and returning so fast I didn't see it then yes, I need to find another way to do this.

The resulting "AFRICAN-AMERICAN" page seems fully loaded almost at once. It is just a 6x6 table. If it is waiting for the page to load I can't see what isn't loading for the five minutes that it is waiting.

Share this post


Link to post
Share on other sites

In using the code _IELinkClickByText ($oFrame, "AFRICAN-AMERICAN ", 0, 1) , you are still telling it to wait to return before moving on. Note that putting a 1 isn't saying halt for 1 ms, but 1 = wait and 0 = don't wait

Let us know how that works for you


While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites

In using the code _IELinkClickByText ($oFrame, "AFRICAN-AMERICAN ", 0, 1) , you are still telling it to wait to return before moving on. Note that putting a 1 isn't saying halt for 1 ms, but 1 = wait and 0 = don't wait

Let us know how that works for you

Geesh, I'm blind as well as ignorant. I did mean it to be 0 and your are correct, it now works. Thank you.

Sue

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  

×
×
  • Create New...