Пример #1
0
        public void SendChatString(string text)
        {
            if (true)
            {
                Stopwatch watch = new Stopwatch();
                FFXIVKeybindDat.Keybind chatKeybind = hotkeys["CMD_CHAT"];

                hook.FocusWindow();
                // Now that our window is focused, we may use SendInput as much as we want

                List <FFXIVHook.KEYBDINPUT> keyInputs = new List <FFXIVHook.KEYBDINPUT>();
                if (IsPerformanceReady())
                {
                    // First reset the keyboard then focus chat input
                    keyInputs.Clear();
                    foreach (FFXIVKeybindDat.Keybind keybind in hotkeys.GetPerformanceKeybinds())
                    {
                        keyInputs.Add(new FFXIVHook.KEYBDINPUT {
                            wVk     = (ushort)keybind.GetKey(),
                            dwFlags = 0x0002,
                        });
                    }
                    hook.SendKeyInput(keyInputs);
                }
                if (Reader.CanGetChatInput() && !memory.ChatInputOpen)
                {
                    while (!memory.ChatInputOpen)
                    {
                        if (chatKeybind is FFXIVKeybindDat.Keybind)
                        {
                            hook.SendSyncKeybind(chatKeybind);
                            System.Threading.Thread.Sleep(100);
                        }
                    }
                }
                if (Reader.CanGetChatInput() && !string.IsNullOrEmpty(memory.ChatInputString))
                {
                    hook.SendSyncKey(Keys.A | Keys.Control);
                    watch.Start();
                    while (!string.IsNullOrEmpty(memory.ChatInputString))
                    {
                        hook.SendSyncKey(Keys.Back);
                        if (watch.ElapsedMilliseconds > 500)
                        {
                            break;
                        }
                        System.Threading.Thread.Sleep(1);
                    }
                    watch.Stop();
                }
                hook.SendString(text);

                bool entered = false;
                if (Reader.CanGetChatInput())
                {
                    watch.Start();

                    while (!memory.ChatInputString.Equals(text))
                    {
                        // ...
                        if (watch.ElapsedMilliseconds > 100)
                        {
                            break;
                        }
                        System.Threading.Thread.Sleep(1);
                    }
                    entered = memory.ChatInputString.Equals(text);
                }
                hook.SendSyncKey(Keys.Enter);
            }
        }