calling the user attention outside of app - c#

I want to create an alarm app for myself. On certain conditions (i need to poll websites) i want my app to inform me and make it HARD TO MISS. So i can take appropriate action or ignore it if i need to do something else.
I wrote a test app and using a BalloonTip (ShowBalloonTip with notifyIcon) isnt great. One of my previous apps brings the window in front of you and does a MessageBox however that doesnt always work or work well (if i somehow miss it or accidentally forget to click ok no futher messages will occur).
What are your suggestions?

You could also make it a system tray application and change the icon out if there is something which requires attention, a la a messenger application. That may not be "hard to miss" but I am trained (for better or worse) to look down at the icon tray when I see something blinking.

Where I work, we have a TimeTracker application (built in house) with which developers are supposed to log what we worked on and when. I am notorious for not using it. So, I wrote my own (Windows Forms) version for my own use which, every hour opens up and takes over my screen:
It is a frameless dialog which consumes the entire screen.
TopMost = True.
On resize, it sets WindowsState = Normal and resizes to fill the screen.
While it is open, it polls for taskmgr.exe and procexp.exe and kills them if found.
It disables the start menu to prevent cmd.exe commands from the menu in Windows 7.
The only way to close it is to enter a log, only then is the OK button shown!
So far, it's working out well - no one has been able to break it!
My less drastic suggestion would be to have a notification which pops up momentarily above the system tray. After a second or two, fade it out. Keep showing the notification every 30 seconds or so until it is dismissed.

Always-on-top window in the corner of the screen?

You could always set your window to be a top most window, make it full screen, and activate it. It would be very, very hard to miss...
Granted, it would also be very annoying, and not something I'd do to other users...
My "real" suggestion would be to use sound along with standard notification methods if this is going to be used by other people, as that's an easy way to grab attention without necessarily killing their workflow. A modeless window that appears in a corner of the screen, especially if combined with sound and color, can be very effective to grab attention.

The industry has been adopting these ambient orb devices and variations of it when such a hard-to-miss notification is required. It is used for tracking the stock-market and for broken-daily-builds.
http://www.ambientdevices.com/cat/orb/MAN_Ambient%20Orb_3-23-03.pdf
Regards

Related

Promoting a NotifyIcon from overflow area without showing a balloon tip

I'm working on a WPF/.NET 4 app that lives in the system tray and periodically shows messages to the user.
I would like to have my NotifyIcon promoted from the overflow area of the system tray to the visible portion each time there is a message. This works fine if I call 'ShowBalloonTip' on my NotifyIcon; however, I don't wish to use the standard OS balloons (I have a custom control for this, which supports multiple instances and custom animations).
Is it possible? It doesn't seem to allow showing an empty/invisible balloon, and disposing/re-adding the icon does not have the intended effect. I wonder if I should look into creating a secondary tray icon each time I have a message (like the Outlook 'new mail' icon) and removing it when my message fades away.
This is not possible. A significant problem with the notification area is that every programmer thinks that his app is important enough to be next to the clock. Modesty is not a programmer's trait and that's a good thing.
The user however sets different priorities. He's liable to run more than three apps that all think they should have the exalted location. This got really out of hand, I've seen screenshots of Win98 machines where 75% of the taskbar was covered with Important Programs.
This was not sustainable and Microsoft did something about it. They added the overflow area to provide a home for notification icons that the user doesn't think are all that important. Being a computer user myself, it is very quickly populated with whatever shovelware icons come with a new machine I purchase. From there, the rate I uninstall this stuff is inversely proportional to the number of times it balloons me with completely useless or inscrutable info. The only ones that ever really survive are the ones that never show a balloon.
A core feature of the overflow area is that programs cannot do anything to elevate themselves back next to the clock. That would completely defeat the point of having it. Other than showing a balloon, the user needs to know where it came from. That better be something meaningful and relevant to the user. If it is not then your uninstaller is the part of your product that gets tested most.
You are a computer yourself and have battled annoying notify icons too. Apply the exact same logic to your own. And don't forget to ask somebody else what they think about yours. And if your notifications are useful enough, this just takes care of itself. Your user will move it back. Because that's what he can do.

How to be OnTop but not OnTop of a full screen application

So I have tried searching for the better part of a day for the answer to a simple question. I want my C# application to popup another winform on a timer and then close it after a delay. Simple enough, done and done. Now my issue is that I want it to actually be on top of other applications UNLESS they are full screen. By that I mean a true full screen application such as a game. I do not want to interfere with such an application since it should take priority over my application.
The issue is that I am using the 'OnTop' property on the popup form and, while it works perfectly for any other applications I have been testing it while playing a full screen game and the form, when it "Show()"s, takes the full screen application and drops it into windowed mode.
Is this the intended effect of the 'OnTop' property with full screen applications? If so is there a way that I can have my form popup on top of normal windowed windows and not interfere with full screen applications?
Any links, example, a kick in the general direction is great. The only hits that I come up with when searching for winforms involving full screen is people trying to get their application into full screen or having their application take focus away from another application.
Thanks on advance.
(I didn't post any code due to it just being a simple winform that is "formX:Show()" on a timer with the "onTop" property set)
(EDIT) So thanks to awilson53 for putting me on the right track I was able to find a method (albeit somewhat picky) to determine if an application is full screen. Seems kinda simple, and an "well duh", answer after all is said and done.
95% of the credit goes to the author of the article: http://www.richard-banks.org/2007/09/how-to-detect-if-another-application-is.html
~5% goes to awilson53 for getting me on the right track. :)
Check out this wrapper for the EnumWindows function. This will allow you to enumerate all open windows and determine their window state. You will want to check the EnumWindowItem.Maximized property, and if it is true set your OnTop property to false. If none of the EnumWindowItem's return Maximised you can set OnTop to true.

Screensaver Hides Desktop

we would like to build a screensaver that shows the desktop and the running applications but prevents user input by showing the login screen. The idea was to build a windows app with no window or a transparent window. However, as soon as the screensaver gets activated the desktop and all applications are hidden from the screen.
Is it possible to start the screensaver without hiding the desktop?
Thx,
bja
Is it possible for you to implement this as something other than a screensaver? I'm assuming that the Windows API does have a method that allows you to tell how long the computer has been idle (otherwise, how does the stuff that manages screensavers do it?), so if you use that you could just set up your application such that it's continuously running as a background process, and will pop up a modal dialog box (or your idea of a transparent window) or something that prompts for the user's login info when the computer has been idle for a certain amount of time.
Why can't you just grab an image of the screen when the SS kicks off. Then use that as the backdrop of your SS.
Vista has a bubbles screen saver that just starts putting bubbles on the screen. Not sure how they do it.
You are better off just creating a full-screen application with a transparent window that starts up on a timer like a screensaver. The screensaver functionality while similar to what you are doing, functions much differently.
As an alternative suggestion, you could always use a service (or background app) to gather the information you want these monitoring tools to display, or even just to grab periodic screenshots of the (hidden) desktop, and then have your screensaver query that app to get the data it needs to display.
That way, you get the benefit (the secure desktop, the usual Windows login sequence, etc.) of a screensaver, but still get to display what you need to.

How can I lock the screen using C#?

I just write my first C# application, which is a scheduler. Once an hour I want to pop-up a dialog and lock the screen for two minutes in order to take a break.
As of now, my application just shows a form on "TopMost" when its time to break and hides it two minutes later.
How can I lock the screen as well? Something similar to the UAC style in Vista.
Eep, misread your question. The UAC dialog of Vista creates a new desktop and shows itself on that. To Create a desktop you can use the CreateDesktop function. You can then use SwitchDesktop to switch to it.
If you truly want to re-create the secure desktop's looks, then you need to take a screenshot first and display that on your form, darkened a little.
Original answer below, which might be of interest too:
Take a look at the LockWorkStation function.
However, you can't programmatically unlock the work station again. That's something the user has to do himself. So you can't easily enfore a break at least two minutes long unless you still resort to your top-level window technique to deny the user his workspace as long as the two minutes are not yet over.
As an alternative to taking a screen grab (which I've also used as an approach in the past under slightly different circumstances) you can also do this by creating a new window (WinForm) that is full screen and on top of all other windows.
If you set the window background colour to solid black then set the opacity to 70-80%, you'll get something that looks like the UAC prompt.
e.g.
formName.WindowState = FormWindowState.Maximized;
formName.FormBorderStyle = FormBorderStyle.None;
formName.Opacity = 0.70;
formName.TopMost = true;
Of course it would be sensible to draw a window on top of this informing the user why the screen has been dimmed, with a counter.
Using something that looks enough like a UAC prompt (which people are accustomed to seeing) to not have people even think twice about it might be enough depending on the use case.
As with the screen grab approach, this on it's own does not prevent a user from bypassing it by using the Windows key, Alt-Tab or Ctrl-Esc to bring up the Start menu, or to switch to other tasks.
Disabling built in key commands requires setting Registry Keys relating to Windows Hotkeys and is a bit more tricky (I think it requires a reboot and can't be toggled on the fly).

How can we prevent popup windows appearing on top of the application?

I have a fullscreen window, and I want to prevent pop up windows that appear at the right bottom corner of my screen. I set the Topmost property to true, but apparently it does not help. I also tried activating the form and giving it the focus once it got deactivated, but that did not help either. What is a way to ignore such windows while the user is engaged with the fullscreen app? I am .NET programming in C#.
You can't do it, this fails the "what if two programs tried to do this" test:
those popups are just normal windows like yours, they also use the same top-most style you are using.
if there was a way to always be above other topmost windows they would have used it too rendering it useless (because the authors of the other apps are just as concerned about the user missing their "super important" notifications as you are about them interfering with your full screen app).
You can try and play dirty tricks to force your window to the top of the top-most z-order, but those popups are likely to use the exact same tricks, again making this all useless (and as an extra bonus all those dirty tricks can turn your app into a compatibility nightmare).
You can disable these balloon notifications using these steps:
Click Start, Run and type regedit
Navigate to the following subkey:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced
In the right pane, create a DWORD value named EnableBalloonTips
Double-click the new entry, and give it a value of 0.
Quit Registry Editor.
Log off Windows (this is not very cool...), and then log back on for the changes to take effect.
if you need help in how doing this by program, don't hesitate to ask ;)
I don't think that you can block all the popups, windows might not let you do that. But you can try with SetWindowPos function and pass it HWND_TOP parameter. It might work a little better than Topmost = true.
I used a sys tray popup control on my personal project SvnRadar written in WPF.
The control is at the http://www.hardcodet.net/projects/wpf-notifyicon written by Philipp Sumi.
Very nice.Only thing you will be need to "detach" it from the SysTray screen coordinates and
make it appear where you wish.
Hope it helps.
Good luck.

Categories