I want my application to be work in minimized state.this application is for detecting change in computer language..For example, I change my language from English to Russia application will detect it. But my application not working in minimized state or in taskbar.I have code for show in taskbar.Is there any solution for this problem? I want application to be detect change language(working) while minimized in toolbar Here I have code for language change detection and to minimized application in toolbar..
private void HandleCurrentLanguage()
{
//CultureInfo.CurrentCulture.ClearCachedData();
//Thread.CurrentThread.CurrentCulture.ClearCachedData();
var newLayout = GetKeyboardLayout(GetWindowThreadProcessId(GetForegroundWindow(), IntPtr.Zero));
if (_currentKeyboardLayout != newLayout)
{
Thread.Sleep(100);
_currentKeyboardLayout = newLayout;
string show = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
// MessageBox.Show(show);
string current_language = InputLanguage.CurrentInputLanguage.Culture.Parent.DisplayName;
string current_layout = InputLanguage.CurrentInputLanguage.LayoutName;
var name = new StringBuilder(_currentKeyboardLayout.ToString());
var keyboardLayoutId = (UInt32)GetKeyboardLayout((UInt32)Thread.CurrentThread.ManagedThreadId);
var languageId = (UInt16)(keyboardLayoutId & 0xFFFF);
var keyboardId = (UInt16)(keyboardLayoutId >> 16);
if (button1.InvokeRequired)
{
button1.Invoke(new MethodInvoker(delegate
{
button1.PerformClick();
}));
}
//CultureInfo.CurrentCulture.ClearCachedData();
//Thread.CurrentThread.CurrentCulture.ClearCachedData();
}
}
// code for minimized application in toolbar
MenuItem exitMenuItem = new MenuItem("Exit", new EventHandler(Exit));
notifyIcon.Icon =SystemTray.Properties.Resources.system_tray;
notifyIcon.Click += new EventHandler(Open);
notifyIcon.ContextMenu = new ContextMenu(new MenuItem[] {
exitMenuItem });
notifyIcon.Visible = true;