Jump to content

newbie question on AdlibEnable and _IEAction


Recommended Posts

Hello, I am working on my first autoit script and got stuck with the following problem:

I need to save an image from a web page (I've tried INetGet according to the tutorial

but it doesn't work, probably because the image is dynamically generated, i.e., the

url for the image invokes a server script), I ended up using _IEAction("saveas"),

which requires manually typing in the file name in the "Save Picture" pop-up window.

I searched on the forum and discovered that AdlibEnable seems to be the solution

for my problem, so here is what I coded:

=============================

...

_IENavigate( $o_IE, $s_img_url )

AdlibEnable( "save_image", 1000 )

_IEAction( $o_IE, "saveas" )

Func save_image()

if WinActive( "Save Picture" ) Then

Send( $s_file_name & @CRLF )

Endif

EndFunc

...

=============================

However the code is not working and I don't know why. When I ran the script,

I would get the "Save Picture" window but the script wouldn't automatically fill

in the file name. It seems like the AdlibEnable function is disabled during the

_IEAction( "saveas" ) call ( if I added a "MsgBox" statement into save_image()

I can only see the message box after I manually handled the "Save Picture"

window) ...

Any insights or suggestions? Many thanks in advance.

Link to comment
Share on other sites

Thanks narayanjr, I followed your suggestion but it still didn't work, is there any way I can verify

that the save_image() is indeed invoked while _IEAction("saveas") is pending?

Send($s_file_name)

Sleep(150)

Send("{ENTER}")

you shouldnt need the @CRLF, and make sure you have the title right and you may want to look into ControlSend()

Link to comment
Share on other sites

The script pauses waiting for manual interaction with the dialog box after doing the SaveAs. You'll need to take a look at the second example for _IEAction in the latest AutoIt version helpfile for a workaround that activates the saveas with simulated keyboard input.

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

Link to comment
Share on other sites

Hi Dale, I did read the 2nd example for _IEAction. If I understand your reply correctly,

I should avoid using "saveas" in this case, however, I have two questions:

1) why didn't AdlibEnable work? I thought it could be used to simulate multi-threading;

2) the only way I can think of to active "saveas" using simulated keyboard input is to

move the cursor over the image, then do "right_click, down, down, down, down, down,

down, ENTER", is that the way to do it? If so, could you show me how to move the

cursor over the image?

Thanks a lot.

The script pauses waiting for manual interaction with the dialog box after doing the SaveAs. You'll need to take a look at the second example for _IEAction in the latest AutoIt version helpfile for a workaround that activates the saveas with simulated keyboard input.

Dale

Link to comment
Share on other sites

I tried the approach suggested by Dale and it worked! Thank you so much for all your

help.

Although I am still wondering why AdlibEnable didn't work ...

Hi Dale, I did read the 2nd example for _IEAction. If I understand your reply correctly,

I should avoid using "saveas" in this case, however, I have two questions:

1) why didn't AdlibEnable work? I thought it could be used to simulate multi-threading;

2) the only way I can think of to active "saveas" using simulated keyboard input is to

move the cursor over the image, then do "right_click, down, down, down, down, down,

down, ENTER", is that the way to do it? If so, could you show me how to move the

cursor over the image?

Thanks a lot.

Link to comment
Share on other sites

AdLib Multi-threading? No. More like time slicing. There is only one thread, so if it stalls everything stops and there is no time to slice.

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

Link to comment
Share on other sites

hmmm, I think I misunderstood the way how Adlib works. So AutoIt only checks to see

whether an Adlib function should be invoked between statements (and during Sleep() I guess)?

Thanks.

AdLib Multi-threading? No. More like time slicing. There is only one thread, so if it stalls everything stops and there is no time to slice.

Dale

Link to comment
Share on other sites

hmmm, I think I misunderstood the way how Adlib works. So AutoIt only checks to see

whether an Adlib function should be invoked between statements (and during Sleep() I guess)?

Thanks.

Essentially, yes.

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

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...