Jump to content

Recommended Posts

Posted (edited)

IE.au3 has an undocumented function called __IELockSetForegroundWindow() that you may be able to use. You can use it to keep a new window from taking focus... a parameter of 1 will lock the window currently in focus, allow you to bring up a new window and then pass a value of 2 to return normal behavior.

Valik wrote this for IE.au3 so taht invisible instances of IE could be prevented from stealing focus when they started.

Give it a shot with some of the other techniques you have here and you should be able to avoid the BlockInput scenario.

Dale

Dale, that is so rad! I like the other undocumented functions too!!! Cool thank you.

However, for some reason when I use the __IELockSetForegroundWindow(1) function like that, the Save button is not clicked. Here's the code:

#include <IE.au3>
Run('Notepad.exe')
Local $WinTitle = 'Untitled - Notepad'
WinWait($WinTitle)
Sleep(1*1000)
ControlSetText($WinTitle,'','Edit1',"Just here for testing"&@CRLF)
Sleep(2*1000)

Global $File = @MyDocumentsDir&'\~0TEST.EXE'
FileDelete($File)

__IELockSetForegroundWindow(1);<<< try this marked out and it will work <<<<<<<<<<<<<<


Local $oIE = ObjCreate('InternetExplorer.Application')
$oIE.visible=0
$oIE.Navigate('http://mozilla.isc.org/pub/mozilla.org/firefox/releases/2.0.0.7/win32/en-US/Firefox%20Setup%202.0.0.7.exe')

Local $winTitle = '0% of ...Firefox%20Setup%202.0.0.7.exe from mozilla.isc.org Completed'
WinWait($winTitle)

Local $winTitle = 'File Download - Security Warning'
WinWait($winTitle)
Sleep(1000)
ControlClick($winTitle,'','Button2')

Local $winTitle = 'Save As'
Local $winText = ''
WinWait($winTitle)
Sleep(1000)
ControlSetText($winTitle,$winText,'Edit1',$File)
Sleep(1000)
ControlClick($winTitle,$winText,'Button2')
Edited by JohnBailey
A decision is a powerful thing
Posted

weird, it appears/seems to me that if LockSetForegroundWindow is used then the 'File Download - Security Warning' window needs focus for the ControlClick (or ControlSend) to work.

A decision is a powerful thing
Posted

Basically, when using _IELockSetForegroundWindow() not only does it still not block the Downloading Windows from stealing the focus but it prevents Control commands from activating the Window's buttons.

#include <IE.au3>
Run('Notepad.exe')
Local $WinTitle = 'Untitled - Notepad'
WinWait($WinTitle)
__IELockSetForegroundWindow(1);<<<mark this out and the below will work;<<<<<<<

Global $File = @MyDocumentsDir&'\~0TEST.EXE'
FileDelete($File)

$oIE=_IECreate('http://mozilla.isc.org/pub/mozilla.org/firefox/releases/2.0.0.7/win32/en-US/Firefox%20Setup%202.0.0.7.exe',0,0,0,-1)

Local $winTitle = 'File Download - Security Warning'
WinWait($winTitle)
ControlClick($winTitle,'','Button2')
A decision is a powerful thing

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
×
×
  • Create New...