Originally published on: Thu, 16 Jul 2009 03:24:17 +0000
Please note! If you're having difficulties compiling the C source code presented below, please see my post: Compiling C from the Command Line with Pelles C
Several years ago, popup ads began to plague my web-browsing experience. At the time, I used only IE as my browser, so I sought out a solution specifically for IE. I wrote a short C program that I called popnix. The version of popnix below is an early console-mode variant of the code. I later put a GUI on the program and gave it to a few friends who were quite happy with the results.
I should state that although this code was really targeted for IE 5 and 6, it still seems to work with version 7 even though IE now has its own blocking mechanisms. I haven't tried IE 8, yet.
Please note that popnix may not function properly if you're running with lower-level privileges as it tries to close an application that it did not invoke.
popnix.c
The code loops continuously, until interrupted with a CTRL-C or a CTRL-BREAK. At one-second intervals, popnix iterates through the list of top-level windows, looking for any with a classname of "IEFrame". If an IEFrame window is found and it's not the first IEFrame window found, popnix tries to remove the popup.
Popnix first displays a message, then invokes a sound via a call to MessageBeep(0), then it finally posts a WM_CLOSE message on the offending window's message queue.
Later versions had more features and were more flexible about allowing some popups but not others. The above reference version attempts to close all other IEFrame popup windows, even if they are "good" popups.
Unless otherwise noted, all code and text entries are Copyright ©2009 by James K. Lawless
Views expressed in this blog are those of the author and do not necessary reflect those of the author's employer. Views expressed in the comments are those of the responding individual.

Save to StumbleUpon
Digg it
Save to Reddit
Share on Facebook
Share on Twitter
More bookmarks
Click **here**
A JavaScript REPL for Android Devices
A Review of Kevin Mitnick's Book Ghost in the Wires
Play MP3 Files with Python on Windows
Java in a Windows EXE with launch4j
Switching a Console Window to Full Screen or Windowed Mode
Rhino JavaScript to EXE with launch4j
Thwarting HTTP Referer Trackbacks
Checking Shift States with DEBUG
TAP : A Command Processor Library
Why Some Web Sites will go Dark on Jan 18th
Book Review : Paull Allen - Idea Man
A 90's Experiment in Online Systems - The U.S. West CommunityLink Service