Jump to content

RTF/DOC in embedded IE


Recommended Posts

I have this in my script:

$zObject = ObjCreate("Shell.Explorer.2")
$zObject_Ctrl = GUICtrlCreateObj($zobject, 0, 120, 993, 577)

And when I go to a page with .rtf or .doc it prompts me to open or save, how can I bypass this?

Link to comment
Share on other sites

You can't "bypass" it, but you can handle it. The popup might be an ordinary window you can automate with standard AutoIt functions like ControlClick(). If it's another embedded IE form, then use _IEAttach() and the other _IE* functions on it.

:blink:

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

Examine the popup with the AutoIt Window Info tool (AU3Info.exe). That will tell you what you're dealing with.

:blink:

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

Why doesn't it register that the window exists :|

Did you examine the popup with AU3Info.exe? What's on the summary tab?

:blink:

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

>>>> Window <<<<
Title:  File Download
Class:  #32770
Position:   498, 370
Size:   404, 282
Style:  0x94C80AC4
ExStyle:    0x00010101
Handle: 0x004E0668

>>>> Control <<<<
Class:  Button
Instance:   2
ClassnameNN:    Button2
Name:   
Advanced (Class):   [CLASS:Button; INSTANCE:2]
ID: 4427
Text:   &Save
Position:   216, 121
Size:   78, 23
ControlClick Coords:    55, 12
Style:  0x50010000
ExStyle:    0x00000004
Handle: 0x0025058E

>>>> Mouse <<<<
Position:   772, 525
Cursor ID:  0
Color:  0xD4D0C8

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
Do you want to open or save this file?
Name:
file.rtf
Type:
Microsoft Word Document, 1.90KB
From:
********* <- website url
&Open
&Save
Cancel
Al&ways ask before opening this type of file
While files from the Internet can be useful, some files can potentially harm your computer. If you do not trust the source, do not open or save this file. <A>What’s the risk?</A>


>>>> Hidden Text <<<<
Publisher:

Link to comment
Share on other sites

I'm guess that line of code never gets executed...

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

Try this:

$hPopup = WinGetHandle("[CLASS:#32770; TITLE:File Download]", "")
If $hPopup Then
    $hButton = ControlGetHandle($hPopup, "", "[CLASS:Button; INSTANCE:2]")
    If $hButton Then
        ControlClick($hPopup, "", $hButton)
        Sleep(1000)
        MsgBox(64, "Click", "Clicked button...", 3)
    Else
        MsgBox(16, "Error", "Failed to get button handle.")
    EndIf
Else
    MsgBox(16, "Error", "Failed to get popup window handle.")
EndIf

:blink:

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

Try this:

$hPopup = WinGetHandle("[CLASS:#32770; TITLE:File Download]", "")
If $hPopup Then
    $hButton = ControlGetHandle($hPopup, "", "[CLASS:Button; INSTANCE:2]")
    If $hButton Then
        ControlClick($hPopup, "", $hButton)
        Sleep(1000)
        MsgBox(64, "Click", "Clicked button...", 3)
    Else
        MsgBox(16, "Error", "Failed to get button handle.")
    EndIf
Else
    MsgBox(16, "Error", "Failed to get popup window handle.")
EndIf

:blink:

Eactly what I needed, thanks.
Link to comment
Share on other sites

Problem solved. I used the MacroGenerator and got this:

#region --- AutoIt Macro Generator V 0.21 beta ---
WinWait("File Download","Do you want to open or save th")
ControlClick("File Download","Do you want to open or save th","Button2")
WinWait("Save As","Save &in:")
ControlClick("Save As","Save &in:","Button2")
WinWait("Save As","C:\Documents and Settings\Admi")
ControlClick("Save As","C:\Documents and Settings\Admi","Button1")
WinWait("Download complete","Download Complete")
ControlClick("Download complete","Download Complete","Button2")
#endregion --- End ---
Link to comment
Share on other sites

You might get the control coordinates and try ControlClick() with the coordinates, and without the control ID. Or maybe ControlFocus() and then ControlSend() "{ENTER}".

:blink:

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

You might get the control coordinates and try ControlClick() with the coordinates, and without the control ID. Or maybe ControlFocus() and then ControlSend() "{ENTER}".

:blink:

I'll try that, the MacroGen code bugs out :\

Link to comment
Share on other sites

Ok, I'm starting to doubt if it's the code that's wrong...

The ControlClick highlights the button... then I did a Send('{ENTER}') and nothing.. so I make a new au3 file and did:

WinActivate('File Download') ; <- worked
ControlClick('File Download', '', 'Button2') ; <- button higlights
Send('{ENTER}') ; <- button pushes down but nothing happens

Then the script ends and I pressed enter myself, what do you know; it works :|

So I'm confused :\

Link to comment
Share on other sites

I did:

WinWait('File Download')
WinActivate('File Download') ; just to make sure
$Pos = ControlGetPos('File Download', '', 'Button2')
MouseMove($Pos[0], $Pos[1], 0)

And it's moving my mouse to the completely wrong spot..

It moving it near the top of the edit control on my child GUI in the program :\

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