Jump to content

Possible to open ie window in the background without losing current windows focus?


Recommended Posts

I wrote a script that constantly polls a number of websites in the background / invisible like:

$oIE = _IECreate ("http://webpage.com/status", 0, 0, 0)

and i have noticed that if you have an IE window open at the time the polling starts, it loses focus of the window and pretty much makes ie inopperable during the time autoit polls all the sites (there are 13 sites takes about 10 seconds to gather the data - if i was typing in this web forum window during the time it went off i'd lose focus of the window and even if I clicked back on it i stilll wouldn't be able to do much (i guess because i'd still be losing focus around once a second) note this problem only occurs if you happen to be messing with an IE window at the time

basically is there a way to truly get data invisibly without causing focus problems?

Don't let that status fool you, I am no advanced memeber!

Link to comment
Share on other sites

You could try using _INetGetSource instead... but I'm not sure that will work any better. Can you post a reproducer code? Do you notice any slowdown if not in an IE window?

Definitely try to post a reproducer, and/or narrow down if there is one specific thing slowing the process down. For example, if the slowdown is with IECreate, can you instead of calling 13 IECreates at once (assuming thats even how your doing it) call only one or two, and have them navigate to the next page when finished instead of closing?

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
Link to comment
Share on other sites

here is an example first hand.... if u run this in the background and attempt to type a reply in an ie window like this form it will lose focus while it does the three checks... then regain focus but you will still need to click in the window to keep typing... >.<

#include <Constants.au3>
#include <IE.au3>
#include <GuiConstants.au3>
#include <Array.au3>
#Include <date.au3>
#include <GUIConstants.au3>
#AutoIt3Wrapper_run_debug_mode=Y

#include <GUIConstants.au3>

$PollTimer = TimerInit()
$Polltime = TimerInit()
$Polltime_till_update = 10000 


While 1
    
    if TimerDiff($PollTimer) >= $Polltime_till_update then
            Status04()
            Status05()
            Status06()
            $PollTimer = TimerInit()  
    endif 
    
WEnd

Func Status04()
$oIE = _IECreate ("http://www.google.com", 0, 0, 0)

_IELoadWait ($oIE)

$sText = _IEBodyReadText ($oIE)

_IEQuit ($oIE)
EndFunc

Func Status05()
$oIE = _IECreate ("http://www.yahoo.com", 0, 0, 0)

_IELoadWait ($oIE)

$sText = _IEBodyReadText ($oIE)

_IEQuit ($oIE)
EndFunc

Func Status06()
$oIE = _IECreate ("http://www.microsoft.com", 0, 0, 0)

_IELoadWait ($oIE)

$sText = _IEBodyReadText ($oIE)

_IEQuit ($oIE)
EndFunc

Don't let that status fool you, I am no advanced memeber!

Link to comment
Share on other sites

You could try using _INetGetSource instead... but I'm not sure that will work any better. Can you post a reproducer code? Do you notice any slowdown if not in an IE window?

if i'm working in a non ie window there is no noticable hang at all.. the script (basicly is monitoring a bunch of server status pages for crap at work we are susposed to manually be looking at) runs all the time every 30 seconds... and the only time i 'feel' it is when i happen to actually be working in a IE window... i personally would just install firefox and make that a painless workaround... but a number of people in my department want to use it to monitor as well and i hardly feel everyone would be peachy keen with my slacker workaround :)

Don't let that status fool you, I am no advanced memeber!

Link to comment
Share on other sites

so basically you want the same thing this guy wants:

http://www.autoitscript.com/forum/index.php?showtopic=74983

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

There is a function in IE.au3 that Valik wrote for me that will lock focus on a window until it is released. Look for __IELockSetForegroundWindow()

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

There is a function in IE.au3 that Valik wrote for me that will lock focus on a window until it is released. Look for __IELockSetForegroundWindow()

Dale

awesome... thx Dale this works just fine

Func Status04()
__IELockSetForegroundWindow($LSFW_LOCK)
$oIE = _IECreate ("http://www.google.com", 0, 0, 0)

_IELoadWait ($oIE)

$sText = _IEBodyReadText ($oIE)

_IEQuit ($oIE)
__IELockSetForegroundWindow($LSFW_UNLOCK)

EndFunc

well its kinda laggy when the ie windows launch but thats perfectly expected :):P

thanks again

Don't let that status fool you, I am no advanced memeber!

Link to comment
Share on other sites

awesome... thx Dale this works just fine

Func Status04()
__IELockSetForegroundWindow($LSFW_LOCK)
$oIE = _IECreate ("http://www.google.com", 0, 0, 0)

_IELoadWait ($oIE)

$sText = _IEBodyReadText ($oIE)

_IEQuit ($oIE)
__IELockSetForegroundWindow($LSFW_UNLOCK)

EndFunc

well its kinda laggy when the ie windows launch but thats perfectly expected :):P

thanks again

It takes time to Create and then close the IE window each time the function is called. If it has to be monitored constantly then you might want to see if you can use _IECreate() outside of the function and _IENavigate inside the function. _IEQuit only when you are finished with _IE*

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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