Beispiel #1
0
        /// <summary>
        /// Instantiates a FFXIVLIB instance.
        /// PID is optionnal but required if multiple FFXIV process are running.
        /// </summary>
        /// <param name="pid">FFXIV PID (optionnal)</param>
        public FFXIVLIB(int pid = 0)
        {
            if (pid != 0)
                ffxiv_process = Process.GetProcessById(pid);
            else
                {
                    Process[] p = Process.GetProcessesByName(Constants.PROCESS_NAME);
                    if (p.Length <= 0)
                        throw new InvalidOperationException("No FFXIV process.");
                    if (p.Length > 1)
                        throw new NotImplementedException("Call the constructor with PID if multiple process.");
                    ffxiv_process = p[0];
                }

            #region Sanity checks

            if (!ffxiv_process.MainWindowTitle.Equals(Constants.WINDOW_TITLE))
                throw new InvalidOperationException("We might not be attaching to FFXIV, is something wrong?");
            if (ffxiv_process.MainModule.ModuleMemorySize < Constants.PROCESS_MMS)
                throw new InvalidOperationException("Wrong MMS.");

            #endregion

            ffxiv_pid = ffxiv_process.Id;
            _mr = MemoryReader.SetInstance(ffxiv_process);
            _ss = new SigScanner(ffxiv_pid, true);
            Ski = SendKeyInput.SetInstance(ffxiv_process.MainWindowHandle);
        }
Beispiel #2
0
        /// <summary>
        /// Instantiates a FFXIVLIB instance.
        /// PID is optional but required if multiple FFXIV process are running.
        /// </summary>
        /// <param name="pid">FFXIV PID (optionnal)</param>
        public FFXIVLIB(int pid = 0)
        {
            if (pid != 0)
                ffxiv_process = Process.GetProcessById(pid);
            else
                {
                    Process[] p = Process.GetProcessesByName(Constants.PROCESS_NAME);
                    if (p.Length <= 0)
                        throw new InvalidOperationException("No FFXIV process.");
                    if (p.Length > 1)
                        throw new InvalidOperationException("Call the constructor with PID if multiple process.");
                    ffxiv_process = p[0];
                }

            Pid = ffxiv_process.Id;
            _mr = MemoryReader.SetInstance(ffxiv_process);
            _ss = new SigScanner(Pid, true);
            Ski = SendKeyInput.SetInstance(ffxiv_process.MainWindowHandle);
        }