Jump to content

Stop a program from flashing in the taskbar


Recommended Posts

Hi.

I'm making an auto-clicker for a certain website, and the taskbar icon of the program keeps flashing whenever I change the site.

Basically, what the program does is get an array of links from the website and visit them one by one.

But every time the link is changed, the taskbar icon flashes.

This is problematic, because it's supposed to run in the background, unnoticed.

Edited code:

#include <GUIConstants.au3>
#include <IE.au3>
#include <INet.au3>

GUICreate("Template", 512, 512)
$glob2IE = _IECreateEmbedded()
$btnGo=GUICtrlCreateButton("Go!",  512-64-8,32,  48,24)
GUICtrlSetFont(-1,12,  400,0,"Arial")
GUICtrlCreateObj($glob2IE, 10,32,  512-20,512-32-10)
GUISetState(@SW_SHOW)

While 1+1=2
 If GUIGetMSG() = $GUI_EVENT_CLOSE Then ExitLoop
 If GUIGetMsg() = $btnGo Then Go()
Wend

Func Go()
$site = "http://www.google.nl"

$oIE = _IECreate($site,  0,
_IENavigate($glob2IE,$site)

$sHTML = _INetGetSource($site)
$oLinks = _IELinkGetCollection($oIE)

$x = 0
Dim $Link_Array[50]
For $oLink In $oLinks
;check if link is not on blacklist

;filter out irrelevant links

 $Link_Array[$x]=$oLink
Next

$z = 0
While $z < $x
  __IELockSetForegroundWindow($LSFW_LOCK)
  _IENavigate($oIE, $Link_Array[$z])
  _IENavigate($glob2IE, $Link_Array[$z])
  __IELockSetForegroundWindow($LSFW_UNLOCK)
 $z += 1
WEnd 
EndFunc

And when I say edited, I mean HEAVILY edited, only showing the relevant parts.

To summarize: whenever the script navigates to a site in the embedded IE object, the program flashes in the taskbar, is there any way to stop it from doing this?

Thanks in advance,

-knight666

Link to comment
Share on other sites

You could try _IEAction "invisible" and get rid of the tray icon altogether -- not sure how the .focus would interact with this... try it.

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

Hey, Dale, love the library. (b ")b

I got rid of the other window entirely, it's now simply an embedded IE object in my program.

The relevant code is now as follows:

__IELockSetForegroundWindow($LSFW_LOCK)
_IENavigate($glob2IE, $site)
_IEAction($glob2IE, "invisible")
WinSetState($globTitle,"",@SW_MINIMIZE )
__IELockSetForegroundWindow($LSFW_UNLOCK)
_IELoadWait($glob2IE)

But the embedded object still steals focus. :)

Edit: Actually, the window only steals focus now, it doesn't flash anymore, so thanks for the partial solution. <_<

Edited by knight666
Link to comment
Share on other sites

Okay, I have a solution, but it's absolutely retarded, so it's not final.

In my program, I simply download the page, and extract the offending Javascript.

This is by far the slowest method evah.

$wait = 20 - Random(-5,5)

$tempsource = _INetGetSource($site)
$tempsource = StringRegExpReplace($tempsource,"\<script\>.*?\<\/script\>","")
$tempsource = StringRegExpReplace($tempsource,"name=Main src=.*?\>","")
$tempsite = StringMid($site,1,StringInStr($site,"/scripts"))
$tempsource = StringRegExpReplace($tempsource,"href=\/scripts\/runner.php\?KE=","href=" & $tempsite & "/scripts/runner.php?KE=")

$website = FileOpen("site" & $number & ".html",2)
FileWrite($website,$tempsource)
FileWriteLine($website,"<META HTTP-EQUIV='REFRESH' CONTENT=" & $wait & ";URL='" & $site & "'>")
FileClose($website)

__IELockSetForegroundWindow($LSFW_LOCK)
_IENavigate($glob2IE, "file:\\" & @ScriptDir & "\site" & $z & ".html")
_IEAction($glob2IE, "invisible")
__IELockSetForegroundWindow($LSFW_UNLOCK)
_IELoadWait($glob2IE)

Sleep($wait*1000+1000)
FileDelete(@ScriptDir & "\site" & $number & ".html")

Suggestions are very much welcome.

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