示例#1
0
    private string GetDefaultSettingsAHK(M_Settings m_Einstellungen)
    {
        string m_DefaultString = "; Bonnyfication GTAV Roleplay Keybinder\r\n" +
                                 "#IfWinActive, Grand Theft Auto V\r\n" +
                                 "#SingleInstance, Force\r\n" +
                                 "#Persistent\r\n" +
                                 "#UseHook, On\r\n" +
                                 "SetKeyDelay, 0, " + m_Einstellungen.Delay.ToString() + "\r\n" +
                                 "t::\r\n" +
                                 "Suspend On\r\n" +
                                 "SendInput t\r\n" +
                                 "Hotkey, Enter, On\r\n" +
                                 "Hotkey, Escape, On\r\n" +
                                 "Hotkey, t, Off\r\n" +
                                 "return\r\n" +
                                 "NumPadEnter::\r\n" +
                                 "Enter::              \r\n" +
                                 "Suspend Permit\r\n" +
                                 "Suspend Off                                \r\n" +
                                 "SendInput {Enter}\r\n" +
                                 "Hotkey, t, On\r\n" +
                                 "Hotkey, Enter, Off\r\n" +
                                 "Hotkey, Escape, Off\r\n" +
                                 "return\r\n" +
                                 "Escape::\r\n" +
                                 "Suspend Permit\r\n" +
                                 "Suspend Off\r\n" +
                                 "SendInput {Escape}\r\n" +
                                 "Hotkey, t, On\r\n" +
                                 "Hotkey, Enter, Off\r\n" +
                                 "Hotkey, Escape, Off\r\n" +
                                 "return\r\n" +
                                 "SendMessage(message)\r\n" +
                                 "{\r\n" +
                                 "SetKeyDelay, 0, 30\r\n" +
                                 "    clipboardBuffer := ClipboardAll\r\n" +
                                 "    Clipboard := message\r\n" +
                                 "    SendEvent, t^v{ENTER}\r\n" +
                                 "    Clipboard := clipboardBuffer\r\n" +
                                 "    return\r\n" +
                                 "}\r\n" +
                                 "SendMessageNoEnter(message)\r\n" +
                                 "{\r\n" +
                                 "SetKeyDelay, 0, 30\r\n" +
                                 "    clipboardBuffer := ClipboardAll\r\n" +
                                 "    Clipboard := message\r\n" +
                                 "    SendEvent, t^v\r\n" +
                                 "    Clipboard := clipboardBuffer\r\n" +
                                 "    return\r\n" +
                                 "}\r\n" +
                                 "Pause::		\r\n"+
                                 "Suspend\r\n" +
                                 "	SendMessage(\"/ooc Der GVMP-Keybinder by Bonnyfication wurde Aktiviert oder Deaktiviert!\")\r\n"+
                                 "return\r\n";

        return(m_DefaultString);
    }
示例#2
0
        private void Execute_Command_Button_Save(object Parameter)
        {
            M_Settings set = new M_Settings();

            int i = 1;

            if (Int32.TryParse(Delay, out i))
            {
                set.Delay = Convert.ToInt32(Delay);
            }
            else
            {
                Bindermessage.ShowWarning("Bitte geben Sie das Delay in Millisekunden an!\nEs sind nur positive Ganzzahlen erlaubt.");
                return;
            }

            if (Int32.TryParse(MultiCommanDelay, out i))
            {
                set.MultiCommanDelay = Convert.ToInt32(MultiCommanDelay);
            }
            else
            {
                Bindermessage.ShowWarning("Bitte geben Sie das MultiCommandDelay in Millisekunden an!\nEs sind nur positive Ganzzahlen erlaubt.");
                return;
            }

            set.Name = Name;

            string m_appdatapath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string m_foldername  = "Bonnyfication";
            string m_FileName    = "Keybinds_Settings.xml";
            string m_Fullpath    = Path.Combine(m_appdatapath, m_foldername, m_FileName);

            try
            {
                XmlSerializer seri = new XmlSerializer(typeof(M_Settings));
                using (StreamWriter writ = new StreamWriter(m_Fullpath))
                {
                    seri.Serialize(writ, set);
                }
            }
            catch (Exception ex)
            {
                Bindermessage.ShowError("Fehler beim Speichern der Einstellungen!\n\nError:\n" + ex);
            }


            _CONTROLLER.RestartKeybinder();
        }
        private void LoadUserSettings()
        {
            string m_appdatapath    = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string m_foldername     = "Bonnyfication";
            string m_FileName       = "Keybinds_Settings.xml";
            string m_Fullpath       = Path.Combine(m_appdatapath, m_foldername, m_FileName);
            string m_FullFolderPath = Path.Combine(m_appdatapath, m_foldername);

            //Check File exists
            System.IO.Directory.CreateDirectory(m_FullFolderPath);
            if (!File.Exists(m_Fullpath))
            {
                // Wenn Datei nicht existiert Standardwerte setzen
                Aktuelle_Einstellungen                  = new M_Settings();
                Aktuelle_Einstellungen.Delay            = 60;
                Aktuelle_Einstellungen.MultiCommanDelay = 1000;
                Aktuelle_Einstellungen.Name             = "Spieler_Name";
                // Speichern
                try
                {
                    XmlSerializer seril = new XmlSerializer(typeof(M_Settings));
                    using (StreamWriter writ = new StreamWriter(m_Fullpath))
                    {
                        seril.Serialize(writ, Aktuelle_Einstellungen);
                    }
                }
                catch (Exception ex)
                {
                    Bindermessage.ShowError("Fehler beim Anlegen der Default Einstellungen!\n\nError:\n" + ex);
                }

                return;
            }

            Aktuelle_Einstellungen = new M_Settings();

            try
            {
                XmlSerializer seri = new XmlSerializer(typeof(M_Settings));
                using (StreamReader read = new StreamReader(m_Fullpath))
                {
                    Aktuelle_Einstellungen = seri.Deserialize(read) as M_Settings;
                }
            }
            catch (Exception ex)
            {
                Bindermessage.ShowError("Fehler beim Laden der Einstellungen!\n\nError:\n" + ex);
            }
        }
示例#4
0
    public void CreateAHKFile(ObservableCollection <M_Binding> ListeKeybinds, M_Settings m_Einstellungen)
    {
        // Directory
        string m_appdatapath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
        string m_foldername  = "Bonnyfication";
        string m_FileName    = "Keybinds_Script.ahk";
        string m_Fullpath    = Path.Combine(m_appdatapath, m_foldername, m_FileName);

        // Lade Default String für die AHK Datei mit Standardfunktionen
        string m_defaultString = GetDefaultSettingsAHK(m_Einstellungen);
        string m_CloseTag      = "return\r\n";

        List <string> m_AuflistungHotkeys = new List <string>();

        foreach (M_Binding k in ListeKeybinds)
        {
            string m_NewKeybind = String.Empty;
            m_NewKeybind += "\r\n";

            // Hole den Befehl im AHK Format
            if (GetKeyString(k) == String.Empty)
            {
                Bindermessage.ShowWarning("Ein Hotkey konnte nicht konvertiert werden!\n\nFehlerhafter Hotkey:\n" + k.Bezeichnung);
                continue;
            }

            m_NewKeybind += GetKeyString(k);

            // Für jedes Command in der Commands Auflistung

            if (k.Auflistung_BindingOptions.Count > 1) // MEHRERE COMMANDS
            {
                for (int i = 0; i < k.Auflistung_BindingOptions.Count(); i++)
                {
                    if (i + 1 == k.Auflistung_BindingOptions.Count())
                    {
                        if (k.AutoEnter)
                        {
                            m_NewKeybind += "SendMessage(\"" + GetEscapedString(k.Auflistung_BindingOptions[i].cmd) + "\")\r\n";
                        }
                        else
                        {
                            m_NewKeybind += "SendMessageNoEnter(\"" + GetEscapedString(k.Auflistung_BindingOptions[i].cmd) + " \")\r\n";
                        }
                    }
                    else
                    {
                        m_NewKeybind += "SendMessage(\"" + GetEscapedString(k.Auflistung_BindingOptions[i].cmd) + "\")\r\n";
                        m_NewKeybind += "Sleep, " + m_Einstellungen.MultiCommanDelay.ToString() + "\r\n";
                    }
                }
            }
            else // Ein Command
            {
                if (k.AutoEnter)
                {
                    m_NewKeybind += "SendMessage(\"" + GetEscapedString(k.Auflistung_BindingOptions[0].cmd) + "\")\r\n";
                }
                else
                {
                    m_NewKeybind += "SendMessageNoEnter(\"" + GetEscapedString(k.Auflistung_BindingOptions[0].cmd) + " \")\r\n";
                }
            }


            m_NewKeybind += m_CloseTag;
            m_AuflistungHotkeys.Add(m_NewKeybind);
        }

        //Create the AHK File
        using (StreamWriter wr = new StreamWriter(m_Fullpath))
        {
            //Write Defaults
            wr.WriteLine(m_defaultString);

            foreach (string s in m_AuflistungHotkeys)
            {
                wr.WriteLine(s);
            }
        }
    }