0

I am trying to Turn On/Off Focus Assist programmatically.

I have tried many ways, (registry/code), but none of them work.

I have found the following code, but this also is not working :

[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);
const int WM_SYSCOMMAND = 0x0112;
const int SC_FOCUSASSIST = 0xF182;
public static void ActivateFocusAssist()
{
    SendMessage(-1, WM_SYSCOMMAND, SC_FOCUSASSIST, 0);
}

The program gets stuck at this method ActivateFocusAssist();

Does anyone have an idea of how to achieve the correct solution?

Compo
  • 36,585
  • 5
  • 27
  • 39
At Work
  • 29
  • 2
  • 1
    Imagine you're a "less than enlightened" programmer and decide that your program is so important that, when you want to tell the user something you'll first turn off focus assist so that they'll definitely see your notification. After their experiences with how programs used icons in the notification area, MS stopped offering API access to tools that are primarily intended to give the *user* control – Damien_The_Unbeliever Apr 24 '23 at 14:12
  • 1
    Does this answer your question? [How to stop Windows 10 feature "focus assist" from being enabled?](https://stackoverflow.com/questions/58745801/how-to-stop-windows-10-feature-focus-assist-from-being-enabled) – orhtej2 Apr 24 '23 at 14:25
  • Where did you get `SC_FOCUSASSIST` from it's not in the docs, and there's no indication it should be? – Charlieface Apr 24 '23 at 15:10

0 Answers0