コード例 #1
0
ファイル: LangDisplay.cs プロジェクト: iamkarlson/Mahou
 public void RefreshLang()
 {
     try{
         var clangname = new System.Globalization.CultureInfo((int)Locales.GetCurrentLocale());
         ChangeLD(clangname.ThreeLetterISOLanguageName.Substring(0, 1).ToUpper() + clangname.ThreeLetterISOLanguageName.Substring(1));
     }
     catch {}
 }
コード例 #2
0
 public static void RefreshLCnMID()
 {
     MMain.locales = Locales.AllList();
     lcnmid.Clear();
     foreach (var lc in locales)
     {
         lcnmid.Add(lc.Lang + "(" + lc.uId + ")");
     }
 }
コード例 #3
0
        public static Process ActiveWindowProcess()
        {
            uint pid = 0;

            WinAPI.GetWindowThreadProcessId(Locales.ActiveWindow(), out pid);
            var prc = Process.GetProcessById((int)pid);

            return(prc);
        }
コード例 #4
0
ファイル: Locales.cs プロジェクト: rajeshwarn/Mahou
        public static Process ActiveWindowProcess()
        {
            uint pid = 0;

            WinAPI.GetWindowThreadProcessId(Locales.ActiveWindow(), out pid);
            Process prc = null;

            try { prc = Process.GetProcessById((int)pid); } catch { Logging.Log("Process with id [" + pid + "] not exist...", 1); }
            return(prc);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: RazorrrZ/Mahou
 [STAThread]         //DO NOT REMOVE THIS
 public static void Main(string[] args)
 {
     Logging.Log("Mahou started.");
     //Catch any error during program runtime
     AppDomain.CurrentDomain.UnhandledException += (obj, arg) => {
         var e = (Exception)arg.ExceptionObject;
         Logging.Log("Unexpected error occured, Mahou exitted, error details:\r\n" + e.Message + "\r\n" + e.StackTrace, 1);
     };
     Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
     using (var mutex = new Mutex(false, "Global\\" + appGUid)) {
         if (!mutex.WaitOne(0, false))
         {
             KMHook.PostMessage((IntPtr)0xffff, ao, 0, 0);
             return;
         }
         if (locales.Length < 2)
         {
             Logging.Log("Too less layouts/locales. Program will exit.");
             Locales.IfLessThan2();
         }
         else
         {
             mahou = new MahouForm();
             InitLanguage();
             //Refreshes icon text language at startup
             mahou.icon.RefreshText(MMain.UI[44], MMain.UI[42], MMain.UI[43]);
             KMHook.ReInitSnippets();
             Application.EnableVisualStyles();                     // Huh i did not noticed that it was missing... '~'
             if (args.Length != 0)
             {
                 if (args[0] == "_!_updated_!_")
                 {
                     Logging.Log("Mahou updated.");
                     mahou.ToggleVisibility();
                     MessageBox.Show(Msgs[0], Msgs[1], MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
             StartHook();
             //for first run, add your locale 1 & locale 2 to settings
             if (MyConfs.Read("Locales", "locale1Lang") == "" && MyConfs.Read("Locales", "locale2Lang") == "")
             {
                 Logging.Log("Initializing locales.");
                 MyConfs.Write("Locales", "locale1uId", locales[0].uId.ToString());
                 MyConfs.Write("Locales", "locale2uId", locales[1].uId.ToString());
                 MyConfs.Write("Locales", "locale1Lang", locales[0].Lang);
                 MyConfs.Write("Locales", "locale2Lang", locales[1].Lang);
             }
             Application.Run();
             StopHook();
         }
     }
 }
コード例 #6
0
ファイル: MoreConfigs.cs プロジェクト: iamkarlson/Mahou
 void RefreshLocales()         // Refreshes locales in comboboxes
 {
     Locales.IfLessThan2();
     MMain.locales = Locales.AllList();
     cbLCLocalesList.Items.Clear();
     cbRCLocalesList.Items.Clear();
     MMain.lcnmid.Clear();
     foreach (Locales.Locale lc in MMain.locales)
     {
         cbLCLocalesList.Items.Add(lc.Lang + "(" + lc.uId + ")");
         cbRCLocalesList.Items.Add(lc.Lang + "(" + lc.uId + ")");
         MMain.lcnmid.Add(lc.Lang + "(" + lc.uId + ")");
     }
 }
コード例 #7
0
ファイル: LangDisplay.cs プロジェクト: RazorrrZ/Mahou
        public void RefreshLang()
        {
            var lcid = (int)Locales.GetCurrentLocale();

            if (lcid > 0)
            {
                var clangname = new System.Globalization.CultureInfo(lcid);
                ChangeLD(clangname.ThreeLetterISOLanguageName.Substring(0, 1).ToUpper() + clangname.ThreeLetterISOLanguageName.Substring(1));
            }
            else
            {
                Logging.Log("Language tooltip text NOT changed, locale id = [" + lcid + "].", 2);
            }
        }
コード例 #8
0
 [STAThread]         //DO NOT REMOVE THIS
 public static void Main(string[] args)
 {
     LogHelper.ConfigureNlog();
     log.Trace("Program start");
     using (var mutex = new Mutex(false, "Global\\" + appGUid)) {
         log.Trace("Mutex created");
         if (!mutex.WaitOne(0, false))
         {
             KMHook.PostMessage((IntPtr)0xffff, ao, 0, 0);
             return;
         }
         if (locales.Length < 2)
         {
             Locales.IfLessThan2();
         }
         else
         {
             mahou = new MahouForm();
             InitLanguage();
             //Refreshes icon text language at startup
             mahou.icon.RefreshText(MMain.UI[44], MMain.UI[42], MMain.UI[43]);
             KMHook.ReInitSnippets();
             Application.EnableVisualStyles();                     // Huh i did not noticed that it was missing... '~'
             if (args.Length != 0)
             {
                 if (args[0] == "_!_updated_!_")
                 {
                     mahou.ToggleVisibility();
                     MessageBox.Show(Msgs[0], Msgs[1], MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
             StartHook();
             //for first run, add your locale 1 & locale 2 to settings
             if (MyConfs.Read("Locales", "locale1Lang") == "" && MyConfs.Read("Locales", "locale2Lang") == "")
             {
                 MyConfs.Write("Locales", "locale1uId", locales[0].uId.ToString());
                 MyConfs.Write("Locales", "locale2uId", locales[1].uId.ToString());
                 MyConfs.Write("Locales", "locale1Lang", locales[0].Lang);
                 MyConfs.Write("Locales", "locale2Lang", locales[1].Lang);
             }
             try {
                 Application.Run();
             } catch (Exception ex) {
                 log.Fatal(ex, "Global error handler caught the exception in app");
             }
             StopHook();
         }
     }
 }
コード例 #9
0
ファイル: MahouForm.cs プロジェクト: iamkarlson/Mahou
 void RefreshLocales()         //Re-adds existed locales to select boxes
 {
     Locales.IfLessThan2();
     MMain.locales = Locales.AllList();
     cbLangOne.Items.Clear();
     cbLangTwo.Items.Clear();
     MMain.lcnmid.Clear();
     foreach (Locales.Locale lc in MMain.locales)
     {
         cbLangOne.Items.Add(lc.Lang + "(" + lc.uId + ")");
         cbLangTwo.Items.Add(lc.Lang + "(" + lc.uId + ")");
         MMain.lcnmid.Add(lc.Lang + "(" + lc.uId + ")");
     }
     try {
         cbLangOne.SelectedIndex = MMain.lcnmid.IndexOf(MMain.MyConfs.Read("Locales", "locale1Lang") + "(" + MMain.MyConfs.Read("Locales", "locale1uId") + ")");
         cbLangTwo.SelectedIndex = MMain.lcnmid.IndexOf(MMain.MyConfs.Read("Locales", "locale2Lang") + "(" + MMain.MyConfs.Read("Locales", "locale2uId") + ")");
     } catch {
         MessageBox.Show(MMain.Msgs[9], MMain.Msgs[5], MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         RefreshLocales();
         cbLangOne.SelectedIndex = 0;
         cbLangTwo.SelectedIndex = 1;
     }
 }
コード例 #10
0
 [STAThread]         //DO NOT REMOVE THIS
 public static void Main(string[] args)
 {
     Application.EnableVisualStyles();             // at first enable styles.
     //Catch any error during program runtime
     AppDomain.CurrentDomain.UnhandledException += (obj, arg) => {
         var e = (Exception)arg.ExceptionObject;
         Logging.Log("Unexpected error occurred, Mahou exited, error details:\r\n" + e.Message + "\r\n" + e.StackTrace, 1);
     };
     Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
     if (System.Globalization.CultureInfo.InstalledUICulture.TwoLetterISOLanguageName == "ru")
     {
         Lang = Languages.Russian;
     }
     MyConfs = new Configs();
     if (Configs.forceAppData && Configs.fine)
     {
         MyConfs.Write("Functions", "AppDataConfigs", "true");
     }
     Logging.Log("Mahou started.");
     using (var mutex = new Mutex(false, GGPU_Mutex)) {
         if (!mutex.WaitOne(0, false))
         {
             if (args.Length > 0)
             {
                 var arg1 = args[0].ToUpper();
                 if (arg1.StartsWith("/R") || arg1.StartsWith("-R") || arg1.StartsWith("R"))
                 {
                     WinAPI.PostMessage((IntPtr)0xffff, re, 0, 0);
                     return;
                 }
             }
             WinAPI.PostMessage((IntPtr)0xffff, ao, 0, 0);
             return;
         }
         if (MMain.MyConfs.ReadBool("Functions", "AppDataConfigs"))
         {
             var mahou_folder_appd = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Mahou");
             if (!Directory.Exists(mahou_folder_appd))
             {
                 Directory.CreateDirectory(mahou_folder_appd);
             }
             if (!File.Exists(Path.Combine(mahou_folder_appd, "Mahou.ini")))                     // Copy main configs to appdata
             {
                 File.Copy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Mahou.ini"),
                           Path.Combine(mahou_folder_appd, "Mahou.ini"), true);
             }
             Configs.filePath = Path.Combine(mahou_folder_appd, "Mahou.ini");
             MyConfs          = new Configs();
         }
         else
         {
             Configs.filePath = Path.Combine(MahouUI.nPath, "Mahou.ini");
         }
         MahouUI.latest_save_dir = Configs.filePath;
         if (MyConfs.ReadBool("FirstStart", "First"))
         {
             if (System.Globalization.CultureInfo.InstalledUICulture.TwoLetterISOLanguageName == "ru")
             {
                 MyConfs.WriteSave("Appearence", "Language", "Русский");
                 MahouUI.InitLanguage();
                 MyConfs.WriteSave("Layouts", "SpecificLayout1", Lang[Languages.Element.SwitchBetween]);
                 MyConfs.WriteSave("FirstStart", "First", "False");
             }
         }
         else
         {
             MahouUI.InitLanguage();
         }
         RefreshLCnMID();
         //for first run, add your locale 1 & locale 2 to settings
         if (MyConfs.Read("Layouts", "MainLayout1") == "" && MyConfs.Read("Layouts", "MainLayout2") == "")
         {
             Logging.Log("Initializing locales.");
             MyConfs.Write("Layouts", "MainLayout1", lcnmid[0]);
             if (lcnmid.Count > 1)
             {
                 MyConfs.Write("Layouts", "MainLayout2", lcnmid[1]);
             }
             MyConfs.WriteToDisk();
         }
         mahou = new MahouUI();
         rif   = new RawInputForm();
         Locales.IfLessThan2();
         if (MyConfs.Read("Layouts", "MainLayout1") == "" && MyConfs.Read("Layouts", "MainLayout2") == "")
         {
             mahou.cbb_MainLayout1.SelectedIndex = 0;
             if (lcnmid.Count > 1)
             {
                 mahou.cbb_MainLayout2.SelectedIndex = 1;
             }
         }
         _evt_hookID = WinAPI.SetWinEventHook(WinAPI.EVENT_SYSTEM_FOREGROUND, WinAPI.EVENT_SYSTEM_FOREGROUND,
                                              IntPtr.Zero, _evt_proc, 0, 0, WinAPI.WINEVENT_OUTOFCONTEXT);
         _LDevt_hookID = WinAPI.SetWinEventHook(WinAPI.EVENT_OBJECT_FOCUS, WinAPI.EVENT_OBJECT_FOCUS,
                                                IntPtr.Zero, _LDevt_proc, 0, 0, WinAPI.WINEVENT_OUTOFCONTEXT);
         if (args.Length != 0)
         {
             if (args[0] == "_!_updated_!_")
             {
                 Logging.Log("Mahou updated.");
                 mahou.ToggleVisibility();
                 MessageBox.Show(Lang[Languages.Element.UpdateComplete], Lang[Languages.Element.UpdateComplete],
                                 MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             if (args[0] == "_!_silent_updated_!_")
             {
                 Logging.Log("Mahou silently updated.");
                 mahou.icon.trIcon.Visible = true;
                 mahou.icon.trIcon.ShowBalloonTip(1000, Lang[Languages.Element.UpdateComplete], "Mahou -> " + mahou.Text, ToolTipIcon.Info);
                 mahou.icon.trIcon.BalloonTipClicked += (_, __) => mahou.ToggleVisibility();
                 if (!mahou.TrayIconVisible)
                 {
                     KMHook.DoLater(() => mahou.Invoke((MethodInvoker) delegate { mahou.icon.trIcon.Visible = false; }), 1005);
                 }
             }
         }
         MyConfs.WriteToDisk();
         if (!string.IsNullOrEmpty(mahou.MainLayout1))
         {
             MahouUI.GlobalLayout = MahouUI.currentLayout = Locales.GetLocaleFromString(mahou.MainLayout1).uId;
         }
         Application.Run();
     }
 }
コード例 #11
0
        public static IntPtr Callback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (MMain.mahou == null || nCode < 0)
            {
                return(WinAPI.CallNextHookEx(_LLHook_ID, nCode, wParam, lParam));
            }
            if (KMHook.ExcludedProgram() && !MahouUI.ChangeLayoutInExcluded)
            {
                return(WinAPI.CallNextHookEx(_LLHook_ID, nCode, wParam, lParam));
            }
            var vk  = Marshal.ReadInt32(lParam);
            var Key = (Keys)vk;

            if (MahouUI.BlockAltUpNOW)
            {
                if ((wParam == (IntPtr)WinAPI.WM_SYSKEYUP || wParam == (IntPtr)WinAPI.WM_KEYUP) &&
                    (Key == Keys.LMenu || Key == Keys.RMenu || Key == Keys.Menu))
                {
                    Debug.WriteLine("ihihihihihihihih-hihih-hi blocked alt :)))))");
                    MahouUI.BlockAltUpNOW = false;
                    return((IntPtr)1);
                }
            }
            SetModifs(Key, wParam);
            if ((alt || alt) && (shift || shift_r) && Key == Keys.Tab)               // mysterious Alt+Shift+Tab, sends Shift Up before Tab down!?
            {
                KMHook.skip_kbd_events++;
            }
            Debug.WriteLine("Alive" + vk + " :: " + wParam);
            #region Redefines
            if (redefines.len > 0)
            {
                var modsstr = KMHook.GetModsStr(ctrl, ctrl_r, shift, shift_r, alt, alt_r, win, win_r).Replace("+", " ").Replace("  ", "").ToLower();
                for (int i = 0; i != redefines.len; i++)
                {
                    if (Key == redefines[i].k)
                    {
                        Logging.Log("[REDEF] > Redefined: " + redefines[i].k + " => " + redefines[i].v);
                        var rli  = redefines_excl_mods[i].ToLower();
                        var redy = true;
                        if (rli == "all" && !(!shift && !alt && !ctrl && !win && !shift_r && !alt_r && !ctrl_r && !win_r))
                        {
                            redy = false;
                        }
                        else
                        {
                            var srli = rli.Split(' ');
                            for (int y = 0; y != srli.Length; y++)
                            {
                                if (!String.IsNullOrEmpty(srli[y]) && modsstr.Contains(srli[y]))
                                {
                                    Logging.Log("[REDEF] > Contains the modifier: " + srli[y]);
                                    redy = false;
                                    break;
                                }
                            }
                        }
                        if (redy)
                        {
                            KMHook.KeybdEvent(redefines[i].v, (wParam.ToInt32() == WinAPI.WM_KEYDOWN || wParam.ToInt32() == WinAPI.WM_SYSKEYDOWN) ? 0 : 2);
                            return((IntPtr)1);
                        }
                        else
                        {
                            Logging.Log("[REDEF] > Redefine cancelled: by mods: " + redefines_excl_mods[i] + " (" + modsstr + ")");
                        }
                    }
                }
            }
            #endregion
            #region Mahou.mm Tray Hotkeys
            var x = new Tuple <bool, bool, bool, bool, bool, bool, bool, Tuple <bool, int> >(alt, alt_r, shift, shift_r, ctrl, ctrl_r, win, new Tuple <bool, int>(win_r, vk));
//				Debug.WriteLine("x_hk: " + Hotkey.tray_hk_to_string(x));
//				Debug.WriteLine("dhk_wait: " +dhk_tray_wait);
//				Debug.WriteLine("dhk_hk: " +dhk_tray_hk);
            if (dhk_tray_wait)
            {
                var hk       = Hotkey.tray_hk_parse(dhk_tray_hk);
                var UpOrDown = OnUpOrDown((Keys)hk.Rest.Item2, wParam);
                if (UpOrDown)
                {
                    var eq = Hotkey.cmp_hotkey(hk, x);
                    //				Debug.WriteLine("dhk_eq: "+eq);
                    if (eq)
                    {
                        Logging.Log("[TR_HK] > Executing action of (double)hotkey: " + dhk_tray_hk_real + " on second hotkey: " + dhk_tray_hk);
                        KMHook.DoSelf(dhk_tray_act, "tray_hotkeys_double");
                        dhk_unset();
                        KMHook.SendModsUp(15, false);                         // less overkill when whole hotkey is being hold
                        return((IntPtr)1);
                    }
                }
            }
            else
            {
                for (int i = 0; i != MahouUI.tray_hotkeys.len; i++)
                {
                    var hk       = Hotkey.tray_hk_parse(MahouUI.tray_hotkeys[i].k);
                    var UpOrDown = OnUpOrDown((Keys)hk.Rest.Item2, wParam);
//					Debug.WriteLine((UpOrDown ? "UP":"DOWN") + " key: " +Key);
                    if (UpOrDown)
                    {
                        if (Hotkey.cmp_hotkey(hk, x))
                        {
                            var d = Hotkey.tray_hk_is_double(MahouUI.tray_hotkeys[i].k);
                            if (d.Item1)
                            {
                                dhk_tray_wait    = true;
                                dhk_tray_hk      = d.Item3;
                                dhk_tray_act     = MahouUI.tray_hotkeys[i].v.Item1;
                                dhk_tray_hk_real = MahouUI.tray_hotkeys[i].k;
                                if (dhk_timer != null)
                                {
                                    dhk_timer.Stop();
                                    dhk_timer.Dispose();
                                }
                                dhk_timer          = new Timer();
                                dhk_timer.Interval = d.Item2;
                                dhk_timer.Tick    += (_, __) => { Debug.WriteLine("Unset timer dhk! " + dhk_timer.Interval + "ms"); dhk_unset(); dhk_timer.Stop(); dhk_timer.Dispose(); };
                                dhk_timer.Start();
                            }
                            else
                            {
                                Logging.Log("[TR_HK] > Executing action of hotkey: " + MahouUI.tray_hotkeys[i].k);
                                dhk_unset();
                                if (MahouUI.tray_hotkeys[i].v.Item2.Contains("hk|c") || MahouUI.tray_hotkeys[i].v.Item2.Contains("hk|s"))
                                {
                                    var altl = ((hk.Item1 || hk.Rest.Item2 == (int)Keys.LMenu) && !hk.Item2 &&                                     // l alt not r alt
                                                !hk.Item3 && !hk.Item4 &&
                                                !hk.Item5 && !hk.Item6 &&
                                                !hk.Item7 && !hk.Rest.Item1);
                                    var altr = (!hk.Item1 && (hk.Item2 || hk.Rest.Item2 == (int)Keys.RMenu) &&
                                                !hk.Item3 && !hk.Item4 &&
                                                !hk.Item5 && !hk.Item6 &&
                                                !hk.Item7 && !hk.Rest.Item1);
                                    if (altl || altr)
                                    {
                                        if (Locales.ActiveWindowClassName(40).Contains("Chrome_WidgetWin"))
                                        {
                                            MahouUI.chrome_window_alt_fix();
                                        }
                                    }
                                    else
                                    {
                                        KMHook.SendModsUp(15, false);                                         // less overkill when whole hotkey is being hold
                                    }
                                    if (altl)
                                    {
                                        KMHook.KeybdEvent(Keys.LMenu, 0);
                                        KMHook.KeybdEvent(Keys.LMenu, 2);
                                    }
                                    if (altr)
                                    {
                                        KMHook.KeybdEvent(Keys.RMenu, 0);
                                        KMHook.KeybdEvent(Keys.RMenu, 2);
                                    }
                                    if ((!hk.Item1 && !hk.Item2 &&
                                         !hk.Item3 && !hk.Item4 &&
                                         !hk.Item5 && !hk.Item6 &&
                                         (hk.Item7 || hk.Rest.Item2 == (int)Keys.LWin) && !hk.Rest.Item1))
                                    {
                                        KMHook.KeybdEvent(Keys.LWin, 0);
                                        KMHook.KeybdEvent(Keys.LWin, 2);
                                    }
                                    if ((!hk.Item1 && !hk.Item2 &&
                                         !hk.Item3 && !hk.Item4 &&
                                         !hk.Item5 && !hk.Item6 &&
                                         !hk.Item7 && (hk.Rest.Item1 || hk.Rest.Item2 == (int)Keys.RWin)))
                                    {
                                        KMHook.KeybdEvent(Keys.RWin, 0);
                                        KMHook.KeybdEvent(Keys.RWin, 2);
                                    }
                                }
                                KMHook.DoSelf(MahouUI.tray_hotkeys[i].v.Item1, "tray_hotkeys");
                                return((IntPtr)1);
                            }
                        }
                    }
                }
            }
            #endregion
            if (MahouUI.SnippetsEnabled)
            {
                if (KMHook.c_snip.Count > 0)
                {
                    var t = MMain.mahou.SnippetsExpandType == "Tab";
                    if (t && Key == Keys.Tab && !shift && !alt && !win && !ctrl && !shift_r && !alt_r && !ctrl_r && !win_r)
                    {
                        WinAPI.keybd_event((byte)Keys.F14, (byte)Keys.F14, 0, 0);
                        return((IntPtr)1);                        // Disable event
                    }
                    if (!t && MMain.mahou.SnippetsExpandType != "Space" && wParam == (IntPtr)WinAPI.WM_KEYDOWN || wParam == (IntPtr)WinAPI.WM_SYSKEYDOWN)
                    {
                        var ms = KMHook.GetModsStr(ctrl, ctrl_r, shift, shift_r, alt, alt_r, win, win_r);
                        ms += Key;
                        var othmatch = ms == MMain.mahou.SnippetsExpKeyOther;
                        Debug.WriteLine("Checking SnippetsExpOther: [" + ms + "] == [" + MMain.mahou.SnippetsExpKeyOther + "] => " + othmatch);
                        if (othmatch)
                        {
                            KMHook.ClearModifiers();
                            WinAPI.keybd_event((byte)Keys.F20, (byte)Keys.F20, 0, 0);
                            return((IntPtr)1);
                        }
                    }
                }
            }
            if (MahouUI.RemapCapslockAsF18)
            {
                bool _shift = !shift, _alt = !alt, _ctrl = !ctrl, _win = !win, _shift_r = !shift_r, _alt_r = !alt_r, _ctrl_r = !ctrl_r, _win_r = !win_r;
                if (Key == Keys.CapsLock)
                {
                    for (int i = 1; i != 5; i++)
                    {
                        var KeyIndex = (int)typeof(MahouUI).GetField("Key" + i).GetValue(MMain.mahou);
                        if (KeyIndex == 8)                           // Shift+CapsLock
                        {
                            _shift   = shift;
                            _shift_r = shift_r;
                        }
                    }
                }
                uint mods = 0;
                if (alt || alt_r)
                {
                    mods += WinAPI.MOD_ALT;
                }
                if (ctrl || ctrl_r)
                {
                    mods += WinAPI.MOD_CONTROL;
                }
                if (shift || shift_r)
                {
                    mods += WinAPI.MOD_SHIFT;
                }
                if (win || win_r)
                {
                    mods += WinAPI.MOD_WIN;
                }
                bool has = MMain.mahou.HasHotkey(new Hotkey(false, (uint)Keys.F18, mods, 77));
                if (has)
                {
                    if (Hotkey.ContainsModifier((int)mods, (int)WinAPI.MOD_SHIFT))
                    {
                        _shift = shift;
                    }
                    _shift_r = shift_r;
                    if (Hotkey.ContainsModifier((int)mods, (int)WinAPI.MOD_ALT))
                    {
                        _alt = alt;
                    }
                    _alt_r = alt_r;
                    if (Hotkey.ContainsModifier((int)mods, (int)WinAPI.MOD_CONTROL))
                    {
                        _ctrl = ctrl;
                    }
                    _ctrl_r = ctrl_r;
                    if (Hotkey.ContainsModifier((int)mods, (int)WinAPI.MOD_WIN))
                    {
                        _win = win;
                    }
                    _win_r = win_r;
                }
                var GJIME = false;
                if (vk >= 240 && vk <= 242)                 // GJ IME's Shift/Alt/Ctrl + CapsLock
                {
                    GJIME = true;
                }
                //			Debug.WriteLine(Key + " " +has + "// " + _shift + " " + _alt + " " + _ctrl + " " + _win + " " + mods + " >> " + (Key == Keys.CapsLock && _shift && _alt && _ctrl && _win));
                if ((Key == Keys.CapsLock || GJIME) && _shift && _alt && _ctrl && _win && _shift_r && _alt_r && _ctrl_r && _win_r)
                {
                    var flags = (int)(KInputs.IsExtended(Key) ? WinAPI.KEYEVENTF_EXTENDEDKEY : 0);
                    if (wParam == (IntPtr)WinAPI.WM_KEYUP)
                    {
                        flags |= (int)WinAPI.KEYEVENTF_KEYUP;
                    }
                    WinAPI.keybd_event((byte)Keys.F18, (byte)Keys.F18, flags, 0);
                    return((IntPtr)1);                    // Disable event
                }
                //			Debug.WriteLine(Marshal.GetLastWin32Error());
            }
            return(WinAPI.CallNextHookEx(_LLHook_ID, nCode, wParam, lParam));
        }
コード例 #12
0
ファイル: jklXHidServ.cs プロジェクト: Makishima/Mahou
        public static void Init()
        {
            if (!MahouUI.ENABLED)
            {
                return;
            }
            if (running)
            {
                bool exist = true;
                if (Environment.Is64BitOperatingSystem)
                {
                    if (Process.GetProcessesByName("jkl").Length > 0)
                    {
                        Logging.Log("[JKL] > JKL already running.");
                    }
                    else
                    {
                        exist = false;
                    }
                }
                else
                {
                    if (Process.GetProcessesByName("jklx86").Length > 0)
                    {
                        Logging.Log("[JKL] > JKLx86 already running.");
                    }
                    else
                    {
                        exist = false;
                    }
                }
                if (!exist)
                {
                    Logging.Log("[JKL] > JKL seems closed, restarting...");
                    running = false;
                }
            }
            if (HWND == IntPtr.Zero)
            {
                Logging.Log("[JKL] > Initializing JKL HWND server...");
                WNDPROC_DELEGATE = jklWndProc;
                var wnd_class = new WinAPI.WNDCLASS();
                wnd_class.lpszClassName = "_XHIDDEN_HWND_SERVER";
                wnd_class.lpfnWndProc   = Marshal.GetFunctionPointerForDelegate(WNDPROC_DELEGATE);
                UInt16 cls_reg    = WinAPI.RegisterClassW(ref wnd_class);
                int    last_error = Marshal.GetLastWin32Error();
                if (cls_reg == 0 && last_error != 0)
                {
                    Logging.Log("[JKL] > Could not register window class, for jkl Hidden Server, err: " + last_error, 1);
                }
                HWND = WinAPI.CreateWindowExW(0, "_XHIDDEN_HWND_SERVER", "_XHIDDEN_HWND_SERVER", 0, 0, 0, 0, 0,
                                              IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
                Logging.Log("[JKL] > SERVER HWND: " + HWND);
            }
            if (!running)
            {
                if (jklExist())
                {
                    if (Environment.Is64BitOperatingSystem)
                    {
                        Logging.Log("[JKL] > Starting jkl.exe...");
                        var jkl = new ProcessStartInfo();
                        jkl.UseShellExecute  = true;
                        jkl.FileName         = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "jkl.exe");
                        jkl.WorkingDirectory = Path.Combine(Path.GetTempPath());
                        Process.Start(jkl);
                    }
                    else
                    {
                        Logging.Log("[JKL] > Starting \"jklx86.exe -msg\"...");
                        var jkl = new ProcessStartInfo();
                        jkl.UseShellExecute  = true;
                        jkl.FileName         = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "jklx86.exe");
                        jkl.Arguments        = "-msg";
                        jkl.WorkingDirectory = Path.Combine(Path.GetTempPath());
                        Process.Start(jkl);
                    }
                    var umsgID = Path.Combine(Path.GetTempPath(), "umsg.id");
                    var tries  = 0;
                    while (!File.Exists(umsgID))
                    {
                        Thread.Sleep(350);
                        tries++;
                        if (tries > 20)
                        {
                            Logging.Log("[JKL] > Error, umsg.id not found after 20 tries by 350 ms timeout.", 1);
                            Destroy();
                            break;
                        }
                    }
                    if (tries <= 20)
                    {
                        Logging.Log("[JKL] > umsg.id found, after " + tries + " tries * 350ms timeout.");
                        Logging.Log("[JKL] > Retrieving umsg.id...");
                        jkluMSG = Int32.Parse(File.ReadAllText(umsgID));
                        File.Delete(umsgID);
//						KMHook.DoLater(() => CycleAllLayouts(Locales.ActiveWindow()), 350);
                        KMHook.DoLater(() => { MahouUI.GlobalLayout = MahouUI.currentLayout = Locales.GetCurrentLocale(); }, 200);
                        running = true;
                    }
                }
                else
                {
                    Logging.Log("[JKL] > " + jklInfoStr, 1);
                }
                if (jkluMSG == -1)
                {
                    KMHook.JKLERR = true;
                }
                else
                {
                    KMHook.JKLERR = false;
                }
                Logging.Log("[JKL] > Init done, umsg: [" + jkluMSG + "], JKLXServ: [" + HWND + "].");
            }
        }
コード例 #13
0
        public MahouForm()
        {
            InitializeComponent();
            res.Tick += (_, __) => {
//				Console.WriteLine("hiding");
                onepass = true;
                langDisplay.HideWnd();
                res.Stop();
            };
            res.Interval = ICheck.Interval * 4;
            ICheck.Tick += (_, __) => {
                if (MMain.MyConfs.ReadBool("Functions", "DTTOnChange"))
                {
                    if (onepass)
                    {
                        latestL = Locales.GetCurrentLocale();
                        onepass = false;
                    }
                    if (latestL != Locales.GetCurrentLocale())
                    {
                        langDisplay.ShowInactiveTopmost();
                        res.Start();
                    }
                }
                else
                {
                    if (ICheckings.IsICursor())
                    {
                        langDisplay.ShowInactiveTopmost();
                    }
                    else
                    {
                        langDisplay.HideWnd();
                    }
                }
                langDisplay.Location = new Point(Cursor.Position.X + MMain.MyConfs.ReadInt("TTipUI", "xpos"),
                                                 Cursor.Position.Y + MMain.MyConfs.ReadInt("TTipUI", "ypos"));
                langDisplay.RefreshLang();
            };
            ScrlCheck.Tick += (_, __) => {
                if (MMain.MyConfs.ReadBool("Functions", "ScrollTip") && !KMHook.self)
                {
                    KMHook.self = true;
                    if (Locales.GetCurrentLocale() == MMain.MyConfs.ReadInt("Locales", "locale1uId"))
                    {
                        if (!Control.IsKeyLocked(Keys.Scroll))                           // Turn on
                        {
                            KMHook.KeybdEvent(Keys.Scroll, 0);
                            KMHook.KeybdEvent(Keys.Scroll, 2);
                        }
                    }
                    else
                    {
                        if (Control.IsKeyLocked(Keys.Scroll))                           // Turn off
                        {
                            KMHook.KeybdEvent(Keys.Scroll, 0);
                            KMHook.KeybdEvent(Keys.Scroll, 2);
                        }
                    }
                    KMHook.self = false;
                }
            };
            ScrlCheck.Interval = 250;
            if (MMain.MyConfs.ReadBool("Functions", "ScrollTip"))
            {
                ScrlCheck.Start();
            }
            KMHook.doublekey.Tick += (_, __) => {
                if (KMHook.hklOK)
                {
                    KMHook.hklOK = false;
                }
                if (KMHook.hksOK)
                {
                    KMHook.hksOK = false;
                }
                if (KMHook.hklineOK)
                {
                    KMHook.hklineOK = false;
                }
                if (KMHook.hkSIOK)
                {
                    KMHook.hkSIOK = false;
                }
                KMHook.doublekey.Stop();
                //Console.WriteLine("Timeout!");
            };
            langDisplay.ChangeColors(ColorTranslator.FromHtml(MMain.MyConfs.Read("Functions", "DLForeColor")),
                                     ColorTranslator.FromHtml(MMain.MyConfs.Read("Functions", "DLBackColor")));
            langDisplay.ChangeSizes((Font)moreConfigs.fcv.ConvertFromString(MMain.MyConfs.Read("TTipUI", "Font")),
                                    MMain.MyConfs.ReadInt("TTipUI", "Height"),
                                    MMain.MyConfs.ReadInt("TTipUI", "Width"));
            ICheck.Interval = MMain.MyConfs.ReadInt("Functions", "DLRefreshRate");
            if (MMain.MyConfs.ReadBool("Functions", "DisplayLang"))
            {
                ICheck.Start();
            }
            icon           = new TrayIcon(MMain.MyConfs.ReadBool("Functions", "IconVisibility"));
            icon.Exit     += exitToolStripMenuItem_Click;
            icon.ShowHide += showHideToolStripMenuItem_Click;
            //↓ Dummy(none) hotkey, makes it possible WndProc to handle messages at startup
            //↓ when form isn't was shown.
            RegisterHotKey(Handle, 0xffff ^ 0xffff, 0, 0);             //HWND must be this form handle
            RefreshIconAll();
            InitializeHotkeys();
            //Background startup check for updates
            if (MMain.MyConfs.ReadBool("Functions", "UpdatesEnabled"))
            {
                var uche = new System.Threading.Thread(update.StartupCheck);
                uche.Name = "Startup Check";
                uche.Start();
            }
        }
コード例 #14
0
 [STAThread]         //DO NOT REMOVE THIS
 public static void Main(string[] args)
 {
     Logging.Log("Mahou started.");
     //Catch any error during program runtime
     AppDomain.CurrentDomain.UnhandledException += (obj, arg) => {
         var e = (Exception)arg.ExceptionObject;
         Logging.Log("Unexpected error occurred, Mahou exited, error details:\r\n" + e.Message + "\r\n" + e.StackTrace, 1);
     };
     Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
     using (var mutex = new Mutex(false, GGPU_Mutex)) {
         if (!mutex.WaitOne(0, false))
         {
             WinAPI.PostMessage((IntPtr)0xffff, ao, 0, 0);
             return;
         }
         if (MMain.MyConfs.ReadBool("Functions", "AppDataConfigs"))
         {
             var mahou_folder_appd = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Mahou");
             if (!Directory.Exists(mahou_folder_appd))
             {
                 Directory.CreateDirectory(mahou_folder_appd);
             }
             Configs.filePath = Path.Combine(mahou_folder_appd, "Mahou.ini");
             MyConfs          = new Configs();
         }
         else
         {
             Configs.filePath = Path.Combine(MahouUI.nPath, "Mahou.ini");
         }
         MahouUI.latest_save_dir = Configs.filePath;
         if (MyConfs.ReadBool("FirstStart", "First"))
         {
             if (System.Globalization.CultureInfo.InstalledUICulture.TwoLetterISOLanguageName == "ru")
             {
                 MyConfs.Write("Appearence", "Language", "Русский");
                 MahouUI.InitLanguage();
                 MyConfs.Write("Layouts", "SpecificLayout1", Lang[Languages.Element.SwitchBetween]);
                 MyConfs.Write("FirstStart", "First", "False");
             }
         }
         else
         {
             MahouUI.InitLanguage();
         }
         foreach (Locales.Locale lc in MMain.locales)
         {
             MMain.lcnmid.Add(lc.Lang + "(" + lc.uId + ")");
         }
         //for first run, add your locale 1 & locale 2 to settings
         if (MyConfs.Read("Layouts", "MainLayout1") == "" && MyConfs.Read("Layouts", "MainLayout2") == "")
         {
             Logging.Log("Initializing locales.");
             MyConfs.Write("Layouts", "MainLayout1", lcnmid[0]);
             MyConfs.Write("Layouts", "MainLayout2", lcnmid[1]);
         }
         mahou = new MahouUI();
         rif   = new RawInputForm();
         Locales.IfLessThan2();
         if (MyConfs.Read("Layouts", "MainLayout1") == "" && MyConfs.Read("Layouts", "MainLayout2") == "")
         {
             mahou.cbb_MainLayout1.SelectedIndex = 0;
             mahou.cbb_MainLayout2.SelectedIndex = 1;
         }
         Application.EnableVisualStyles();                 // Huh i did not noticed that it was missing... '~'
         _evt_hookID = WinAPI.SetWinEventHook(WinAPI.EVENT_SYSTEM_FOREGROUND, WinAPI.EVENT_SYSTEM_FOREGROUND,
                                              IntPtr.Zero, _evt_proc, 0, 0, WinAPI.WINEVENT_OUTOFCONTEXT);
         KMHook.CheckLayoutLater.Tick += (_, __) => { MahouUI.GlobalLayout = Locales.GetCurrentLocale(); KMHook.CheckLayoutLater.Stop(); };
         if (args.Length != 0)
         {
             if (args[0] == "_!_updated_!_")
             {
                 Logging.Log("Mahou updated.");
                 mahou.ToggleVisibility();
                 MessageBox.Show(Lang[Languages.Element.UpdateComplete], Lang[Languages.Element.UpdateComplete], MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         MahouUI.GlobalLayout = MahouUI.currentLayout = Locales.GetLocaleFromString(mahou.MainLayout1).uId;
         Application.Run();
     }
 }
コード例 #15
0
ファイル: jklXHidServ.cs プロジェクト: m0narX14/Mahou
        public static void Init()
        {
            if (!MahouUI.ENABLED)
            {
                return;
            }
            if (running)
            {
                bool exist = true;
                if (Environment.Is64BitOperatingSystem)
                {
                    if (Process.GetProcessesByName("jkl").Length > 0)
                    {
                        Logging.Log("[JKL] > JKL already running.");
                    }
                    else
                    {
                        exist = false;
                    }
                }
                else
                {
                    if (Process.GetProcessesByName("jklx86").Length > 0)
                    {
                        Logging.Log("[JKL] > JKLx86 already running.");
                    }
                    else
                    {
                        exist = false;
                    }
                }
                if (!exist)
                {
                    Logging.Log("[JKL] > JKL seems closed, restarting...");
                    running = false;
                }
            }
            if (s == null)
            {
                Logging.Log("[JKL] > Initializing JKL HWND server...");
                s = new HServer();
                Logging.Log("[JKL] > SERVER HWND: " + s.Handle + " WinTitle: " + s.Text);
            }
            if (!running)
            {
                if (jklExist())
                {
                    if (Environment.Is64BitOperatingSystem)
                    {
                        Logging.Log("[JKL] > Starting jkl.exe...");
                        var jkl = new ProcessStartInfo();
                        jkl.UseShellExecute  = true;
                        jkl.FileName         = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "jkl.exe");
                        jkl.WorkingDirectory = Path.Combine(Path.GetTempPath());
                        Process.Start(jkl);
                    }
                    else
                    {
                        Logging.Log("[JKL] > Starting \"jklx86.exe -msg\"...");
                        var jkl = new ProcessStartInfo();
                        jkl.UseShellExecute  = true;
                        jkl.FileName         = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "jklx86.exe");
                        jkl.Arguments        = "-msg";
                        jkl.WorkingDirectory = Path.Combine(Path.GetTempPath());
                        Process.Start(jkl);
                    }
                    var umsgID = Path.Combine(Path.GetTempPath(), "umsg.id");
                    var tries  = 0;
                    while (!File.Exists(umsgID))
                    {
                        Thread.Sleep(350);
                        tries++;
                        if (tries > 20)
                        {
                            Logging.Log("[JKL] > Error, umsg.id not found after 20 tries by 350 ms timeout.", 1);
                            Destroy();
                            break;
                        }
                    }
                    if (tries <= 20)
                    {
                        Logging.Log("[JKL] > umsg.id found, after " + tries + " tries * 350ms timeout.");
                        Logging.Log("[JKL] > Retrieving umsg.id...");
                        jkluMSG = Int32.Parse(File.ReadAllText(umsgID));
                        File.Delete(umsgID);
//						KMHook.DoLater(() => CycleAllLayouts(Locales.ActiveWindow()), 350);
                        KMHook.DoLater(() => { MahouUI.GlobalLayout = MahouUI.currentLayout = Locales.GetCurrentLocale(); }, 200);
                        running = true;
                    }
                }
                else
                {
                    Logging.Log("[JKL] > " + jklInfoStr, 1);
                }
                if (jkluMSG == -1)
                {
                    KMHook.JKLERR = true;
                }
                else
                {
                    KMHook.JKLERR = false;
                }
                Logging.Log("[JKL] > Init done, umsg: [" + jkluMSG + "], JKLXServ: [" + s.Handle + "].");
            }
        }
コード例 #16
0
        /// <summary>
        /// Refresh language text.
        /// </summary>
        public void RefreshLang()
        {
            if (!Visible)
            {
                return;
            }
            uint cLid = Locales.GetCurrentLocale();

            if (cLid == 0)
            {
                cLid = MahouUI.currentLayout;
            }
            if (MMain.mahou.OneLayout)
            {
                cLid = MahouUI.GlobalLayout;
            }
            if (MMain.mahou.LDCaretTransparentBack_temp && caretDisplay)
            {
                transparentBG = true;
            }
            else if (MMain.mahou.LDMouseTransparentBack_temp && mouseDisplay)
            {
                transparentBG = true;
            }
            else
            {
                transparentBG = false;
            }
            var notTwo = false;

            if ((cLid & 0xffff) > 0)
            {
                var clangname = new System.Globalization.CultureInfo((int)(cLid & 0xffff));
                if (MMain.mahou.DiffAppearenceForLayouts && !DisplayFlag)
                {
                    if (cLid == Locales.GetLocaleFromString(MMain.mahou.MainLayout1).uId)
                    {
                        ChangeColors(MMain.mahou.Layout1Font_temp, MMain.mahou.Layout1Fore_temp,
                                     MMain.mahou.Layout1Back_temp, MMain.mahou.Layout1TransparentBack_temp);
                        ChangeSize(MMain.mahou.Layout1Height_temp, MMain.mahou.Layout1Width_temp);
                        ChangeLD(MMain.mahou.Layout1TText);
                    }
                    else if (cLid == Locales.GetLocaleFromString(MMain.mahou.MainLayout2).uId)
                    {
                        ChangeColors(MMain.mahou.Layout2Font_temp, MMain.mahou.Layout2Fore_temp,
                                     MMain.mahou.Layout2Back_temp, MMain.mahou.Layout2TransparentBack_temp);
                        ChangeSize(MMain.mahou.Layout2Height_temp, MMain.mahou.Layout2Width_temp);
                        ChangeLD(MMain.mahou.Layout2TText);
                    }
                    else
                    {
                        notTwo = true;
                    }
                }
                else
                {
                    notTwo = true;
                }
                if (notTwo)
                {
                    if (mouseDisplay)
                    {
                        ChangeColors(MMain.mahou.LDMouseFont_temp, MMain.mahou.LDMouseFore_temp,
                                     MMain.mahou.LDMouseBack_temp, MMain.mahou.LDMouseTransparentBack_temp);
                        ChangeSize(MMain.mahou.LDMouseHeight_temp, MMain.mahou.LDMouseWidth_temp);
                    }
                    if (caretDisplay)
                    {
                        ChangeColors(MMain.mahou.LDCaretFont_temp, MMain.mahou.LDCaretFore_temp,
                                     MMain.mahou.LDCaretBack_temp, MMain.mahou.LDCaretTransparentBack_temp);
                        ChangeSize(MMain.mahou.LDCaretHeight_temp, MMain.mahou.LDCaretWidth_temp);
                    }
                    ChangeLD(clangname.ThreeLetterISOLanguageName.Substring(0, 1).ToUpper() + clangname.ThreeLetterISOLanguageName.Substring(1));
                }
                if (!MMain.mahou.DiffAppearenceForLayouts || lbLang.Text == "")
                {
                    ChangeLD(clangname.ThreeLetterISOLanguageName.Substring(0, 1).ToUpper() + clangname.ThreeLetterISOLanguageName.Substring(1));
                }
                if (transparentBG)
                {
                    TransparencyKey = BackColor = lbLang.BackColor = pct_UpperArrow.BackColor = Color.Pink;
                }
                if (lastTransparentBG != transparentBG)
                {
                    SetVisInvis();
                }
                lastTransparentBG = transparentBG;
                if ((caretDisplay && !MahouUI.caretLTUpperArrow) || (mouseDisplay && !MahouUI.mouseLTUpperArrow) || onInit)
                {
                    ReSize(); onInit = false;
                }
            }
            else
            {
                Logging.Log("Language tooltip text NOT changed, locale id = [" + cLid + "].", 2);
            }
        }
コード例 #17
0
ファイル: Program.cs プロジェクト: grengray/Mahou
        [STAThread]         //DO NOT REMOVE THIS
        public static void Main(string[] args)
        {
            Logging.Log("Mahou started.");
            //Catch any error during program runtime
            AppDomain.CurrentDomain.UnhandledException += (obj, arg) => {
                var e = (Exception)arg.ExceptionObject;
                Logging.Log("Unexpected error occurred, Mahou exited, error details:\r\n" + e.Message + "\r\n" + e.StackTrace, 1);
            };
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            using (var mutex = new Mutex(false, "Global\\" + appGUid)) {
                if (!mutex.WaitOne(0, false))
                {
                    WinAPI.PostMessage((IntPtr)0xffff, ao, 0, 0);
                    return;
                }
                if (locales.Length < 2)
                {
                    Logging.Log("Too less layouts/locales. Program will exit.");
                    Locales.IfLessThan2();
                }
                else
                {
                    if (MyConfs.ReadBool("FirstStart", "First"))
                    {
                        if (System.Globalization.CultureInfo.InstalledUICulture.TwoLetterISOLanguageName == "ru")
                        {
                            MyConfs.Write("Appearence", "Language", "Русский");
                            MahouUI.InitLanguage();
                            MyConfs.Write("Layouts", "SpecificLayout1", Lang[Languages.Element.SwitchBetween]);
                            MyConfs.Write("FirstStart", "First", "False");
                        }
                    }
                    else
                    {
                        MahouUI.InitLanguage();
                    }
                    foreach (Locales.Locale lc in MMain.locales)
                    {
                        MMain.lcnmid.Add(lc.Lang + "(" + lc.uId + ")");
                    }
                    //for first run, add your locale 1 & locale 2 to settings
                    if (MyConfs.Read("Layouts", "MainLayout1") == "" && MyConfs.Read("Layouts", "MainLayout2") == "")
                    {
                        Logging.Log("Initializing locales.");
                        MyConfs.Write("Layouts", "MainLayout1", lcnmid[0]);
                        MyConfs.Write("Layouts", "MainLayout2", lcnmid[1]);
                    }
                    mahou = new MahouUI();
                    if (MyConfs.Read("Layouts", "MainLayout1") == "" && MyConfs.Read("Layouts", "MainLayout2") == "")
                    {
                        mahou.cbb_MainLayout1.SelectedIndex = 0;
                        mahou.cbb_MainLayout2.SelectedIndex = 1;
                    }
                    //Refreshes icon text language at startup
//					mahou.icon.RefreshText(MMain.UI[44], MMain.UI[42], MMain.UI[43]);
                    KMHook.ReInitSnippets();
                    Application.EnableVisualStyles();                     // Huh i did not noticed that it was missing... '~'
                    _evt_hookID = WinAPI.SetWinEventHook(WinAPI.EVENT_SYSTEM_FOREGROUND, WinAPI.EVENT_SYSTEM_FOREGROUND,
                                                         IntPtr.Zero, _evt_proc, 0, 0, WinAPI.WINEVENT_OUTOFCONTEXT);
                    KMHook.CheckLayoutLater.Tick += (_, __) => { MahouUI.GlobalLayout = Locales.GetCurrentLocale(); KMHook.CheckLayoutLater.Stop(); };
                    if (args.Length != 0)
                    {
                        if (args[0] == "_!_updated_!_")
                        {
                            Logging.Log("Mahou updated.");
                            mahou.ToggleVisibility();
                            MessageBox.Show(Lang[Languages.Element.UpdateComplete], Lang[Languages.Element.UpdateComplete], MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    StartHook();
                    MahouUI.GlobalLayout = MahouUI.currentLayout = Locales.GetLocaleFromString(mahou.MainLayout1).uId;
                    Application.Run();
                    StopHook();
                }
            }
        }