Mechanism to bring attention to LINQPad window and tab?
I have some scripts that are very long running (we're talking days) intended to check a resource and synchronize locally. Most of the time, it is able to run with no problems but occasionally, it will require user interaction.
Is there a mechanism that I can use to "notify" the Linqpad window, or more specifically, a specific script?
I'm thinking, flash the icon, the toolbar, maybe show the name of the script in the title flashing. Maybe a notification in the tool tray perhaps?
Comments
Util.HostWindowHandle
will give you the handle of the main Linqpad UI program so if you could use PInvokeThen when you call
SetForegroundWindow(Util.HostWindowHandle);
It will flash the LinqPad taskbar.
You could also call
and (providing your query had been saved as least once), then it would switch to the correct query, but that is probably a bad idea in case you happen to be typing in another query at that time.
It would also be fair simple to send a ToastNotification, but I'm not sure if it could actually capture any actions from it.
SetForegroundWindow
steals keyboard focus, which might be an annoyance:FlashWindow can be used instead.
Are you sure? I thought that behaviour was changed years ago and if you are working in another window, it flashed the taskbar icon instead. (A quick test shows if have notepad open it doesn't lose the focus when the taskbar flashes)
Actually that's probably better anyway as it will work if the focus is in another query in LinqPad whereas SetForegroundWindow won't.
More on
SetForegroundWindow
.