-1

How to get FLASHWINFO struct from window handle in C#?

I have not found anything on this topic on StackOverflow. Here's the article Force window to blink when a particular event occurs in C# / WPF

UPDATE: I want to check from one application if another application has a flashing window in it.

Community
  • 1
  • 1
yW0K5o
  • 913
  • 1
  • 17
  • 32
  • you need allocate and initialize it yourself, but not *get* – RbMm May 15 '17 at 20:51
  • The code in the answer given in the link you posted in your question shows exactly how you do it. Frankly, open your eyes and look at the source code. –  May 15 '17 at 20:51
  • I want to check if windows flashing in another application. – yW0K5o May 15 '17 at 20:52
  • @RbMm I need opposite task. See my previous comment. – yW0K5o May 15 '17 at 20:53
  • @elgonzo I need opposite task. See my previous comment. – yW0K5o May 15 '17 at 20:53
  • I'd be willing to bet there's no way to do this. The flashing state is temporary, so I doubt Windows stores the `FLASHWINFO` data anywhere except as needed during the animation itself. It almost certainly isn't queryable after it is applied via the `FlashWindowEx`. – Michael Gunter May 15 '17 at 20:54
  • 2
    Probably, the best you can do is to hook FlashWindowEx. http://stackoverflow.com/questions/23695718/how-to-create-a-global-32-64bit-hook-for-flashwindowex – Michael Gunter May 15 '17 at 20:56
  • @MichaelGunter I'll try it and let you know results. Working with Windows hooks may be a hard task. – yW0K5o May 15 '17 at 21:00
  • Hard and error-prone. Assuming for the moment that you can hook `FlashWindowEx`, you then have to calculate the exact amount of time the flash operation will take and then wipe out your program's state when that time has elapsed. – Michael Gunter May 15 '17 at 21:03
  • FWIW: I just used Resharper C++ to search a Windows program for usages of `FLASHWINFO` and `PFLASHWINFO`. The only place that this struct is used in the entire windows API is in the `FlashWindowEx` API. Therefore, there is no API that will return this info or fill in an existing structure with it (i.e. there is no way to query this info). – Michael Gunter May 15 '17 at 21:07
  • @MichaelGunter you should just post it as answer. – Alexei Levenkov May 15 '17 at 21:11
  • exist partial solution by `RegisterWindowMessageW(L"SHELLHOOK");` and then call [`RegisterShellHookWindow`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms644989(v=vs.85).aspx) - we will receive this registered message with `HSHELL_FLASH` for this window handle (in *lParam*) when it begin flashed and with `HSHELL_RUDEAPPACTIVATED` when end flashed – RbMm May 15 '17 at 22:31

1 Answers1

1

Unfortunately, there is no way to do this. The flashing state is temporary, and windows won't store this information except internally, temporarily, as needed by the animation itself. I used Resharper C++ to search for usages of the FLASHWINFO struct and it's corresponding pointer type PFLASHWINFO. The only instance of this structure being used is in the FlashWindowEx method itself. There simply is no (public) API for querying this info.

You may be able to build something by hooking FlashWindowEx, but it's likely to be a little difficult to get right. Assuming for the moment that you can hook FlashWindowEx, you then have to calculate the exact amount of time the flash operation will take and then wipe out your program's state when that time has elapsed. If you'd like to try this approach, see this answer.

Community
  • 1
  • 1
Michael Gunter
  • 12,528
  • 1
  • 24
  • 58