コード例 #1
0
        private void w_KeyboardMods_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                KeyboardModsInfo info = (KeyboardModsInfo)e.Argument;

                //////////////
                // Backwards Writing Keyboard MOD Vars
                bool             backwardWriting  = false;
                List <KeyStatus> bkWritingKeys    = new List <KeyStatus>();
                List <Keys>      BKWDetectionList = new List <Keys>();

                BKWDetectionList.AddRange(MakeKeyList(Keys.A, Keys.Z));
                BKWDetectionList.AddRange(MakeKeyList(Keys.D0, Keys.D9));

                BKWDetectionList.AddRange(MakeKeyList(Keys.Space, Keys.Space));
                BKWDetectionList.AddRange(MakeKeyList(Keys.OemMinus, Keys.OemMinus));
                BKWDetectionList.AddRange(MakeKeyList(Keys.Oemcomma, Keys.Oemcomma));
                BKWDetectionList.AddRange(MakeKeyList(Keys.OemPeriod, Keys.OemPeriod));
                BKWDetectionList.AddRange(MakeKeyList(Keys.Oemplus, Keys.Oemplus));
                BKWDetectionList.AddRange(MakeKeyList((Keys)0xDC, (Keys)0xDC));
                BKWDetectionList.AddRange(MakeKeyList((Keys)0xDB, (Keys)0xDB));
                BKWDetectionList.AddRange(MakeKeyList((Keys)0xE2, (Keys)0xE2));
                BKWDetectionList.AddRange(MakeKeyList((Keys)0xBA, (Keys)0xBA));
                BKWDetectionList.AddRange(MakeKeyList((Keys)0xDD, (Keys)0xDD));
                BKWDetectionList.AddRange(MakeKeyList((Keys)0xC0, (Keys)0xC0));
                BKWDetectionList.AddRange(MakeKeyList((Keys)0xDE, (Keys)0xDE));
                BKWDetectionList.AddRange(MakeKeyList((Keys)0xBF, (Keys)0xBF));

                //////////////
                // Leet Speak Keyboard MOD Vars
                bool             leetSpeak       = false;
                List <KeyStatus> lsWritingKeys   = new List <KeyStatus>();
                List <Keys>      LSDetectionList = new List <Keys>();

                LSDetectionList.AddRange(MakeKeyList(Keys.A, Keys.Z));

                CharDictionary[] LeetSpeakDic = new CharDictionary[]
                {
                    new CharDictionary(Keys.A, "4"),
                    new CharDictionary(Keys.B, "8"),
                    new CharDictionary(Keys.C, "("),
                    new CharDictionary(Keys.D, "|)"),
                    new CharDictionary(Keys.E, "3"),
                    new CharDictionary(Keys.F, "|="),
                    new CharDictionary(Keys.G, "6"),
                    new CharDictionary(Keys.H, "|-|"),
                    new CharDictionary(Keys.I, "1"),
                    new CharDictionary(Keys.J, ".|"),
                    new CharDictionary(Keys.K, "|<"),
                    new CharDictionary(Keys.L, "|_"),
                    new CharDictionary(Keys.M, "/\\/\\"),
                    new CharDictionary(Keys.N, "|\\|"),
                    new CharDictionary(Keys.O, "0"),
                    new CharDictionary(Keys.P, "P"),
                    new CharDictionary(Keys.Q, "9"),
                    new CharDictionary(Keys.R, "2"),
                    new CharDictionary(Keys.S, "5"),
                    new CharDictionary(Keys.T, "7"),
                    new CharDictionary(Keys.U, "|_|"),
                    new CharDictionary(Keys.V, "\\/"),
                    new CharDictionary(Keys.W, "\\/\\/"),
                    new CharDictionary(Keys.X, "X"),
                    new CharDictionary(Keys.Y, "Y"),
                    new CharDictionary(Keys.Z, "Z"),
                    new CharDictionary((Keys)0xDD, "Å"),
                    new CharDictionary((Keys)0xC0, "Ø"),
                    new CharDictionary((Keys)0xDE, "Æ")
                };

                CharDictionary[] LeetSpeakDicEasy = new CharDictionary[]
                {
                    new CharDictionary(Keys.A, "4"),
                    new CharDictionary(Keys.B, "8"),
                    new CharDictionary(Keys.C, "c"),
                    new CharDictionary(Keys.D, "d"),
                    new CharDictionary(Keys.E, "3"),
                    new CharDictionary(Keys.F, "f"),
                    new CharDictionary(Keys.G, "6"),
                    new CharDictionary(Keys.H, "h"),
                    new CharDictionary(Keys.I, "1"),
                    new CharDictionary(Keys.J, "j"),
                    new CharDictionary(Keys.K, "k"),
                    new CharDictionary(Keys.L, "l"),
                    new CharDictionary(Keys.M, "m"),
                    new CharDictionary(Keys.N, "n"),
                    new CharDictionary(Keys.O, "0"),
                    new CharDictionary(Keys.P, "p"),
                    new CharDictionary(Keys.Q, "9"),
                    new CharDictionary(Keys.R, "2"),
                    new CharDictionary(Keys.S, "5"),
                    new CharDictionary(Keys.T, "7"),
                    new CharDictionary(Keys.U, "u"),
                    new CharDictionary(Keys.V, "v"),
                    new CharDictionary(Keys.W, "w"),
                    new CharDictionary(Keys.X, "x"),
                    new CharDictionary(Keys.Y, "y"),
                    new CharDictionary(Keys.Z, "z"),
                    new CharDictionary((Keys)0xDD, "å"),    // Å
                    new CharDictionary((Keys)0xC0, "ø"),    // Ø
                    new CharDictionary((Keys)0xDE, "æ")     // Æ
                };

                //////////////
                // Random Capital Letters Keyboard MOD Vars
                bool randomCaps = false;

                //////////////
                // Morse Code Keyboard MOD vars
                bool             morseCode       = false;
                List <KeyStatus> mcWritingKeys   = new List <KeyStatus>();
                List <Keys>      MCDetectionList = new List <Keys>();

                MCDetectionList.AddRange(MakeKeyList(Keys.A, Keys.Z));
                MCDetectionList.AddRange(MakeKeyList(Keys.D0, Keys.D9));
                MCDetectionList.AddRange(MakeKeyList(Keys.Space, Keys.Space));

                CharDictionary[] MorseCodeDict = new CharDictionary[]
                {
                    new CharDictionary(Keys.A, ".-"),
                    new CharDictionary(Keys.B, "-..."),
                    new CharDictionary(Keys.C, "-.-."),
                    new CharDictionary(Keys.D, "-.."),
                    new CharDictionary(Keys.E, "."),
                    new CharDictionary(Keys.F, "..-."),
                    new CharDictionary(Keys.G, "--."),
                    new CharDictionary(Keys.H, "...."),
                    new CharDictionary(Keys.I, ".."),
                    new CharDictionary(Keys.J, ".---"),
                    new CharDictionary(Keys.K, "-.-"),
                    new CharDictionary(Keys.L, ".-.."),
                    new CharDictionary(Keys.M, "--"),
                    new CharDictionary(Keys.N, "-."),
                    new CharDictionary(Keys.O, "---"),
                    new CharDictionary(Keys.P, ".--."),
                    new CharDictionary(Keys.Q, "--.-"),
                    new CharDictionary(Keys.R, ".-."),
                    new CharDictionary(Keys.S, "..."),
                    new CharDictionary(Keys.T, "-"),
                    new CharDictionary(Keys.U, "..-"),
                    new CharDictionary(Keys.V, "...-"),
                    new CharDictionary(Keys.W, ".--"),
                    new CharDictionary(Keys.X, "-..-"),
                    new CharDictionary(Keys.Y, "-.--"),
                    new CharDictionary(Keys.Z, "--.."),

                    new CharDictionary(Keys.D0, ".----"),
                    new CharDictionary(Keys.D1, "..---"),
                    new CharDictionary(Keys.D2, "...--"),
                    new CharDictionary(Keys.D3, "....-"),
                    new CharDictionary(Keys.D4, "....."),
                    new CharDictionary(Keys.D5, "-...."),
                    new CharDictionary(Keys.D6, "--..."),
                    new CharDictionary(Keys.D7, "---.."),
                    new CharDictionary(Keys.D8, "---.."),
                    new CharDictionary(Keys.D9, "-----"),

                    new CharDictionary(Keys.Space, "   ")
                };

                //////////////

                while (true)
                {
                    /***********************************/
                    // Backwards Writing Keyboard MOD
                    //
                    // these states run 1 time per state change
                    if (!backwardWriting && info.GetMenuChecked(c_KBM_BackwardsTyping))
                    {
                        backwardWriting = true;
                    }
                    else if (backwardWriting && !info.GetMenuChecked(c_KBM_BackwardsTyping))
                    {
                        backwardWriting = false;
                    }

                    if (backwardWriting)
                    {// always runs if activated, main mod code
                        System.Diagnostics.Debug.WriteLine("BackwardsWriting Activated.");

                        // get pressed keys
                        bkWritingKeys = DetectKeys(bkWritingKeys, BKWDetectionList);

                        if (bkWritingKeys.Count > 0)
                        {
                            for (int i = 0; i < bkWritingKeys.Count; i++)
                            {
                                if (!bkWritingKeys[i].Checked)
                                {
                                    SendKeys.SendWait("{LEFT}");

                                    KeyStatus ks = bkWritingKeys[i];
                                    ks.Checked = true;

                                    bkWritingKeys[i] = ks;
                                }
                            }
                        }
                    }
                    else
                    {// always runs if deactivated
                    }

                    /***********************************/
                    // Leet Speak Keyboard MOD
                    //
                    // these states run 1 time per state change
                    if (!leetSpeak && info.GetMenuChecked(c_KBM_LeetSpeak))
                    {
                        leetSpeak = true;
                    }
                    else if (leetSpeak && !info.GetMenuChecked(c_KBM_LeetSpeak))
                    {
                        leetSpeak = false;
                    }

                    if (leetSpeak)
                    {// always runs if activated, main mod code
                     //System.Diagnostics.Debug.WriteLine("LeetSpeak Activated.");

                        lsWritingKeys = DetectKeys(lsWritingKeys, LSDetectionList);

                        if (lsWritingKeys.Count > 0)
                        {
                            for (int i = 0; i < lsWritingKeys.Count; i++)
                            {
                                if (!lsWritingKeys[i].Checked)
                                {
                                    KeyStatus ks = lsWritingKeys[i];
                                    ks.Checked = true;

                                    lsWritingKeys[i] = ks;

                                    SendKeys.SendWait("{BS}");

                                    // get char from dict
                                    for (int j = 0; j < LeetSpeakDicEasy.Length; j++)
                                    {
                                        if (LeetSpeakDicEasy[j].Key == lsWritingKeys[i].Key)
                                        {
                                            SendKeys.SendWait(FixSpecialChars(LeetSpeakDicEasy[j].Char));
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {// always runs if deactivated
                    }

                    /***********************************/
                    // Random Capital Letters Keyboard MOD
                    //
                    // these states run 1 time per state change
                    if (!randomCaps && info.GetMenuChecked(c_KBM_RandomCaps))
                    {
                        randomCaps = true;
                    }
                    else if (randomCaps && !info.GetMenuChecked(c_KBM_RandomCaps))
                    {
                        if (GetKeyState((int)KeyboardEvent.EventKeys.VK_CAPITAL) == (short)0x1)
                        {
                            SetCaps(true);
                            SetCaps(false);
                        }

                        randomCaps = false;
                    }

                    if (randomCaps)
                    {// always runs if activated, main mod code
                        System.Diagnostics.Debug.WriteLine("RandomCaps Activated.");

                        SetCaps(true);
                        SetCaps(false);

                        Thread.Sleep(100);
                    }
                    else
                    {// always runs if deactivated
                    }

                    /***********************************/
                    // Morse Code Keyboard MOD
                    //
                    // these states run 1 time per state change
                    if (!morseCode && info.GetMenuChecked(c_KBM_MorseCode))
                    {
                        morseCode = true;
                    }
                    else if (morseCode && !info.GetMenuChecked(c_KBM_MorseCode))
                    {
                        morseCode = false;
                    }

                    if (morseCode)
                    {// always runs if activated, main mod code
                     //System.Diagnostics.Debug.WriteLine("MorseCode Activated.");

                        mcWritingKeys = DetectKeys(mcWritingKeys, MCDetectionList);

                        if (mcWritingKeys.Count > 0)
                        {
                            System.Diagnostics.Debug.WriteLine("yes");
                            for (int i = 0; i < mcWritingKeys.Count; i++)
                            {
                                if (!mcWritingKeys[i].Checked)
                                {
                                    KeyStatus ks = mcWritingKeys[i];
                                    ks.Checked = true;

                                    mcWritingKeys[i] = ks;

                                    SendKeys.SendWait("{BS}");

                                    // get char from dict
                                    for (int j = 0; j < MorseCodeDict.Length; j++)
                                    {
                                        if (MorseCodeDict[j].Key == mcWritingKeys[i].Key)
                                        {
                                            SendKeys.SendWait(FixSpecialChars(MorseCodeDict[j].Char) + " ");
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {// always runs if deactivated
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n\n############ STACKTRACE:\n" + ex.StackTrace + "\n####################\n IF YOU SEE THIS MESSAGE, PRESS CTRL+C WHILE HAVING THIS MESSAGE ACTIVE AND SEND TO DEVELOPER (SNIXTHO).");
            }
        }