There are many frameworks that do not use native Windows controls, and “draw” controls on the window themselves. So do, for example, WPF and Qt. Desktop Viber is written just on Qt.
Try using UI Automation instead for your purposes. For example, this program works for me with VLC controls, which is written in Qt:
class Program { static void Main(string[] args) { // находим процесс var vlcProcess = Process.GetProcessesByName("vlc").FirstOrDefault(); // и его главное окно var window = AutomationElement.FromHandle(vlcProcess.MainWindowHandle); // находим в нём меню var menuBar = window.FirstChildByType(ControlType.MenuBar); // в нём пункт "Медиа" var mediaMenu = menuBar.FirstDescendantByTypeAndName( ControlType.MenuItem, "Медиа"); // раскрываем его mediaMenu.GetPattern<InvokePattern>().Invoke(); // даём приложению успеть раскрыть меню и создать подэлементы Thread.Sleep(100); // находим в меню "Медиа" пункт "Выход" var exitMenu = mediaMenu.FirstDescendantByTypeAndName( ControlType.MenuItem, "Выход"); // и выбираем его exitMenu.GetPattern<InvokePattern>().Invoke(); Thread.Sleep(100); } } static class AutomationHelpers { static public T GetPattern<T>(this AutomationElement element) where T : BasePattern { var pattern = (AutomationPattern)typeof(T).GetField("Pattern").GetValue(null); return (T)element.GetCurrentPattern(pattern); } static public AutomationElement FirstChildByType( this AutomationElement element, ControlType ct) { return element.FindFirst( TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ct)); } static public AutomationElement FirstDescendantByTypeAndName( this AutomationElement element, ControlType ct, string name) { return element.FindFirst( TreeScope.Descendants, new AndCondition( new PropertyCondition(AutomationElement.ControlTypeProperty, ct), new PropertyCondition(AutomationElement.NameProperty, name))); } static public AutomationElement FindWindowFrom(AutomationElement control) { var walker = TreeWalker.ControlViewWalker; while (control.Current.ControlType != ControlType.Window) control = walker.GetParent(control); return control; } }
To view controls that support UI Automation, you need the Inspect utility .