Jump to content

Don't Steal Focus!


 Share

Recommended Posts

I am attempting to create a replacement for the System Tray Bubble that will not steal focus from the currently active window when it pops up. Something like Google Talk's or Outlook's custom popup.

I started with some example popup code from here on the forum but cannot seem to get it topmost without grabbing control from the currently active window.

#include <GUIConstants.au3>

;Sleep so I can click on a different window
Sleep(10000)

;Create popup
GUICreate("My Popup", 300, 200, -1, -1, BitOR($WS_POPUP, $WS_DISABLED), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetState (@SW_SHOW)       ; will display an empty dialog box

;Sleep so I can view if it stole focus
Sleep(10000)

Why write a custom popup balloon? Microsoft's handling of balloon timeouts leaves much to be desired, and it seems when I'm not hovering over the systray icon it keeps sending the TraySetOnEvent($TRAY_EVENT_MOUSEOVER, "_TrayHover") anyways, I'm to the point where I'd rather build and destroy a GUI than annoy the end user with continuous bubbles. Thanks in advance for any assistance, even if it's "here is the post you missed in your search of the forum" type thing.

HEX

Link to comment
Share on other sites

Try this:

#include <GUIConstants.au3>

;Sleep so I can click on a different window
Sleep(10000)

;Create popup
$GUIhandle = GUICreate("My Popup", 300, 200, -1, -1, BitOR($WS_POPUP, $WS_DISABLED), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
WinSetOnTop($GUIHandle, "", 1)
GUISetState (@SW_SHOWNOACTIVATE)       ; will display an empty dialog box

;Sleep so I can view if it stole focus
Sleep(10000)
Link to comment
Share on other sites

I am attempting to create a replacement for the System Tray Bubble that will not steal focus from the currently active window when it pops up. Something like Google Talk's or Outlook's custom popup.

I started with some example popup code from here on the forum but cannot seem to get it topmost without grabbing control from the currently active window.

#include <GUIConstants.au3>

;Sleep so I can click on a different window
Sleep(10000)

;Create popup
GUICreate("My Popup", 300, 200, -1, -1, BitOR($WS_POPUP, $WS_DISABLED), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetState (@SW_SHOW)       ; will display an empty dialog box

;Sleep so I can view if it stole focus
Sleep(10000)

Why write a custom popup balloon? Microsoft's handling of balloon timeouts leaves much to be desired, and it seems when I'm not hovering over the systray icon it keeps sending the TraySetOnEvent($TRAY_EVENT_MOUSEOVER, "_TrayHover") anyways, I'm to the point where I'd rather build and destroy a GUI than annoy the end user with continuous bubbles. Thanks in advance for any assistance, even if it's "here is the post you missed in your search of the forum" type thing.

HEX

Welcome to the forum. Have you considered using a native (non AutoIt) ToolTip control? While you could build your own custom popup, there is a lot of work already done for you if you use a ToolTip. Might want to take a look at the ToolTip demos in Auto3Lib to see what I mean. If you get stuck, feel free to PM me and I'll see if I can help you along.
Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

Gabburd: Thanks, I was too busy concentrating on GUICreate styles to check into the @SW_x options!

PaulIA: Thanks, I saw $TTS_BALLOON mentioned in another post during my search for balloon info but skipped it as being too complex for my limited GUI knowledge. I've grabbed your library and the help file looks excellent. Since I'm just in the Prototype stage of building my own balloon I'll try this approach.

I'm actually a long time lurker, been reading the forums for years until I had to register for some forum feature. :shocked:

HEX

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