Jump to content

select "save" in IE10 "Do you want to run or save" message.


Go to solution Solved by Coded4Decades,

Recommended Posts

How can I get the following code to work?  By the way, I just used PDF995 as an easy demonstration.  My actual problem is from a complicated autoit script that navigates a website and gets a nearly identical security message.

#Include <IE.au3>
; shellexecutewait("C:\EfgMdl\closeIE.exe") ;kills all previous iexplore.exe processes without causing "do you want to restore ..." messages
Dim $oIE
$oIE = _IECreate("http://www.pdf995.com/download.html", 1, 1, 1, 1) ; url, try to attach, visible, wait before loading, take focus
_IELoadWait($oIE)
_IENavigate($oIE, "http://www.software995.net/bin/pdf995s.exe")

$oForm = _IEFormGetCollection($oIE,1)

$oButton = _IEFormElementGetCollection($oForm,0)
        _IEAction($oButton,'click')
    Sleep(10000)
    If WinExists("Create PDF") Then
        ; ControlSend("Create PDF","Do you want to run or save","[CLASS:Button; INSTANCE:2]", "{ENTER}")
        ; ControlSend("Create PDF","Do you want to run or save","[CLASS:Button; INSTANCE:2]", "%s")
        ControlSend("Create PDF","Do you want to run or save","[CLASS:DirectUIHWND:INSTANCE:1]", "%S")
        MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, "did it work?") ;### Debug MSGBOX
    EndIf

And here is the info from using Finder to hover over the yellow security message at the bottom of the screen.

 

>>>> Window <<<<
Title:    Create PDF - Windows Internet Explorer
Class:    IEFrame
Position:    422, 91
Size:    1024, 738
Style:    0x16CF0000
ExStyle:    0x00000100
Handle:    0x00000000000F09EC

>>>> Control <<<<
Class:    DirectUIHWND
Instance:    1
ClassnameNN:    DirectUIHWND1
Name:    
Advanced (Class):    [CLASS:DirectUIHWND; INSTANCE:1]
ID:    
Text:    
Position:    100, 645
Size:    808, 85
ControlClick Coords:    686, 67
Style:    0x56000000
ExStyle:    0x00000000
Handle:    0x00000000001408D2

>>>> Mouse <<<<
Position:    1216, 803
Cursor ID:    0
Color:    0xE8E8E8

>>>> StatusBar <<<<
1:    
2:    

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
Navigation Bar
Address Bar
http://www.pdf995.com/download.html
Address Combo Control
Page Control
Favorites and Tools Bar
Command Bar
Command Bar
ITBarHost
Menu Bar
Create PDF - Windows Internet Explorer
Zoom Level


>>>> Hidden Text <<<<
 

Edited by Coded4Decades
Link to comment
Share on other sites

Clearly clicking the "Save" does not bypass security.  It INVOKES the security scan on the downloaded file. 

But, since you seem to be suspicious of my motives, I will explain further.

i am trying to download about 1000 files from the internet.   Our company enters applications onto a government website for about 200 of our customers.  Once a week we go to that website and download the current status of 5 years of applications.

Currently this is done using a Windows 7 IE7 autoit program written by a good consultant (my son is very smart !!!!)  In IE7 the "save" dialog is a separate window that can be easily manipulated. But, the program broke when the computer was upgraded to IE10 2 years ago. My son tried to fix but decided to downgraded back to IE. He is now working on a much bigger project for a huge multinational so he does not have time to work for us. He suggested I post to this forum and somebody would be sure to help.  I am also a programmer, but I am new to Autoit.

I have figured out how to do by  an Excel Vba environment using sendkeys "%s", but I don't want to convert 1000 lines of code from Autoit to vba.

Surely the most be a way doing this in Autoit under IE10?

Link to comment
Share on other sites

Universalist:

WOW, that is one heavy duty link !!!  It uses over a dozen techniques that I don't understand and I'll admit it intimidates me.

Also, the code seems to close the windows security scan which I do NOT like. I would much prefer the security scan to run.

 

I think I will postpone trying that for a day or two.

It still seems to me that Send or Sendcontrol might do the trick in a more straightforward manner.

Link to comment
Share on other sites

The "alt" symbol for Autoit Send is not the same as vba Sendkeys. Autoit uses !  while vba uses %.

Ugh, that really caused me to waste a bunch of time.

The following does what I want very simply.  But, I still have a problem.  Is there some way to change the sleep(8000) so that it simply waits for the IE information bar to appear?  Since I am download 1000 files, that wastes almost 3 hours of time. 

 

#Include <IE.au3>
Dim $oIE
 shellexecutewait("C:EfgMdlcloseIE.exe") ;kills all previous iexplore.exe processes without causing "do you want to restore ..." messages
$oIE = _IECreate("http://www.pdf995.com/download.html", 1, 1, 1, 1) ; url, try to attach, visible, wait before loading, take focus
_IELoadWait($oIE)
_IENavigate($oIE, "http://www.software995.net/bin/pdf995s.exe")
    Sleep(8000)
    send("!ns")

Link to comment
Share on other sites

You might be able to do something similar to this.  It's just an example but if it gives you an idea. I use this to recognize when the save bar pops up at the bottom of the screen.  Another user helped me with it here a long time ago.

Do
If WinActive("[Class:IEFrame]") Then
        Local $hIE = WinGetHandle("[Class:IEFrame]")
        Local $hCtrl = ControlGetHandle($hIE, "", "[ClassNN:DirectUIHWND1]")
        Local $aPos = ControlGetPos($hIE, "", $hCtrl)
        Local $aWinPos = WinGetPos($hIE)
        If ControlCommand($hIE, "", $hCtrl, "IsVisible") AND $aPos[1] > .75 * $aWinPos[3] Then ; Check if the control is in the bottom 25% of the page.
            ControlClick($hIE, "", $hCtrl, "primary", 1, $aPos[2] - 160, $aPos[3] - 30)
            Sleep(500)
            ControlSend($hIE, "", $hCtrl, "{down}{down}{enter}")
        EndIf
    EndIf
sleep(100)
Until WinExists("Save As")
Link to comment
Share on other sites

Adventurer RULES THE WORLD.

That was exactly what I needed.

One problem though.  The send($file) is getting truncated sometimes even if I change Sleep(50) to Sleep(100). I have now set it up to 200 which seems to work. but I bet it fails in real life.

Opt("TrayIconDebug", 1) ; 0 = off, 1 = on
#Include <IE.au3>
Dim $oIE
$FILE = "c:\aaatmp\test.pdf"
$FILEx = "c:\aaatmp\testx.pdf"
FileDelete($FILE)
FileDelete($FILEx)
 shellexecutewait("C:\EfgMdl\closeIE.exe") ;kills all previous iexplore.exe processes without causing "do you want to restore ..." messages
$oIE = _IECreate("http://www.pdf995.com/download.html", 1, 1, 1, 1) ; url, try to attach, visible, wait before loading, take focus
_IELoadWait($oIE)
_IENavigate($oIE, "http://www.software995.net/bin/pdf995s.exe")
Do
    If WinActive("[Class:IEFrame]") Then
        Local $hIE = WinGetHandle("[Class:IEFrame]")
        Local $hCtrl = ControlGetHandle($hIE, "", "[ClassNN:DirectUIHWND1]")
        Local $aPos = ControlGetPos($hIE, "", $hCtrl)
        Local $aWinPos = WinGetPos($hIE)
        If ControlCommand($hIE, "", $hCtrl, "IsVisible") AND $aPos[1] > .75 * $aWinPos[3] Then ; Check if the control is in the bottom 25% of the page.
            ControlClick($hIE, "", $hCtrl, "primary", 1, $aPos[2] - 160, $aPos[3] - 30)
            Sleep(500)
            ControlSend($hIE, "", $hCtrl, "{down}{down}{enter}")
        EndIf
    EndIf
    sleep(100)
Until WinExists("Save As")

        Winactivate("Save As")
        send("!n")
        sleep(50) ; without this, then next send often gets truncated.
        SEND($FILE)
        send("!s")
        
while winexists("Save As")
    sleep(100)
WEnd
    WHILE NOT FILEEXISTS($FILE)
        SLEEP(100)
    WEND
msgbox(0,"","File exists > Rename it",3)
        while FILEMOVE($FILE,$FILEx) <> 1
                sleep(100)
        WEnd
        filemove ($filex,$file)
        _IEQuit($oIE)
msgbox(0,"","done")
Edited by Coded4Decades
Link to comment
Share on other sites

  • Solution

I always have to insert at least one random Sleep(xxx) where xxx is based on guesswork.

It happens every time I do anything important with internet automation and I HATE it  !!!!

In this case, I needed random sleep(500) near line 26.  If  I go much lower, the code stops working.

Nonetheless, I finally beat this program to death and it now appears to be reliable.

Opt("TrayIconDebug", 1) ; 0 = off, 1 = on
#Include <IE.au3>
Dim $oIE
$path = "c:\keep empty\"
local $actfile
$FILEx = "c:\keep empty\testx.pdf"
 shellexecutewait("C:\EfgMdl\closeIE.exe") ;kills all previous iexplore.exe processes without causing "do you want to restore ..." messages

#cs
        For this script to work, the internet explorer default download directory must be changed to c:\keep empty\
        Open ie > Ctrl J > options > browse  then OK all the way out and close IE
#ce
FileDelete($path & "*")

$oIE = _IECreate("http://www.pdf995.com/download.html", 0, 1, 1, 1) ; url, try to attach, visible, wait before loading, take focus
_IELoadWait($oIE)
_IENavigate($oIE, "http://www.software995.net/bin/pdf995s.exe")
while 1 ; wait for the information bar to appear at the bottom of the sheet.
    If WinActive("[Class:IEFrame]") Then
        Local $hIE = WinGetHandle("[Class:IEFrame]")
        Local $hCtrl = ControlGetHandle($hIE, "", "[ClassNN:DirectUIHWND1]")
        Local $aPos = ControlGetPos($hIE, "", $hCtrl)
        Local $aWinPos = WinGetPos($hIE)
        If ControlCommand($hIE, "", $hCtrl, "IsVisible") AND $aPos[1] > .75 * $aWinPos[3] Then ; Check if the control is in the bottom 25% of the page.
            ControlClick($hIE, "", $hCtrl, "primary", 1, $aPos[2] - 160, $aPos[3] - 30)
            sleep(500)
            exitloop
        EndIf
    EndIf
    sleep(100)
wend
_DownloadIt()
_iequit($oie)

msgbox(0,"","done",10)

func _DownloadIt()
    Do
        send ("!ns")
        sleep(100)
        $actFile = FileFindFirstFile($path& "*.*")
    until $actfile <> - 1
    $actFile = $path & FileFindNextFile($actfile)
    if stringinstr($actfile,"partial") > 0 Then
            while fileexists($actfile)
            wend
            $actFile = FileFindFirstFile($path& "*.*")
            $actFile = $path & FileFindNextFile($actfile)
        EndIf

    while FILEMOVE( $actFile,$FILEx) <> 1
        sleep(100)
    WEnd
    filemove ($filex,$actfile)
EndFunc
Edited by Coded4Decades
Link to comment
Share on other sites

  • 1 year later...

 

You might be able to do something similar to this.  It's just an example but if it gives you an idea. I use this to recognize when the save bar pops up at the bottom of the screen.  Another user helped me with it here a long time ago.

Do
If WinActive("[Class:IEFrame]") Then
        Local $hIE = WinGetHandle("[Class:IEFrame]")
        Local $hCtrl = ControlGetHandle($hIE, "", "[ClassNN:DirectUIHWND1]")
        Local $aPos = ControlGetPos($hIE, "", $hCtrl)
        Local $aWinPos = WinGetPos($hIE)
        If ControlCommand($hIE, "", $hCtrl, "IsVisible") AND $aPos[1] > .75 * $aWinPos[3] Then ; Check if the control is in the bottom 25% of the page.
            ControlClick($hIE, "", $hCtrl, "primary", 1, $aPos[2] - 160, $aPos[3] - 30)
            Sleep(500)
            ControlSend($hIE, "", $hCtrl, "{down}{down}{enter}")
        EndIf
    EndIf
sleep(100)
Until WinExists("Save As")

Thank you for this!

Are you able to tell me what part of the code needs to be changed if I want to click Open instead of Save?

 

Thanks,

Robert

 

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