コード例 #1
0
        private void RefreshUI()
        {
            if (Program.accounts.Length > 4)
            {
                heightofgui = 143 + 17 * (Program.accounts.Length - 4);
                this.SetBounds(Location.X, Location.Y, Size.Width, heightofgui);
            }
            this.listViewAccounts.Items.Clear();

            // Run through already open GW clients to see if accounts are already active.
            foreach (Process p in Process.GetProcessesByName("Gw"))
            {
                if (p.Threads.Count == 1)
                {
                    continue;
                }
                GWCAMemory m = new GWCAMemory(p);
                GWMem.FindAddressesIfNeeded(m);
                string str = m.ReadWString(GWMem.EmailAddPtr, 64);
                for (int i = 0; i < Program.accounts.Length; ++i)
                {
                    if (str == Program.accounts[i].email)
                    {
                        Program.accounts[i].active  = true;
                        Program.accounts[i].process = m;
                        break;
                    }
                }
            }

            // Fill out data.
            for (int i = 0; i < Program.accounts.Length; ++i)
            {
                listViewAccounts.Items.Add(new ListViewItem(
                                               new string[] {
                    Program.accounts[i].character,
                    Program.accounts[i].active ? "Active" : "Inactive"
                },
                                               "gw-icon"
                                               ));
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: DubbleClick/gwlauncher
        internal static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (Mutex.TryOpenExisting(GwlMutexName, out gwlMutex))
            {
                return;
            }

            gwlMutex = new Mutex(true, GwlMutexName);

            settings = GlobalSettings.Load();


            accounts = new AccountManager("Accounts.json");
            foreach (Account t in accounts)
            {
                t.active = false;
            }

            using (var mf = new MainForm())
            {
                mf.Location     = new System.Drawing.Point(-1000, -1000);
                mf.FormClosing += (object sender, FormClosingEventArgs e) => { Program.settings.Save(); };

                mainthread = new Thread(() =>
                {
                    var mainClosed = false;
                    mf.FormClosed += (s, a) => { mainClosed = true; };
                    while (!mainClosed)
                    {
                        var sleep = 5000;
                        while (mf.needtolaunch.Count > 0)
                        {
                            int i        = mf.needtolaunch.Dequeue();
                            var ok       = true;
                            Account a    = accounts[i];
                            GWCAMemory m = MulticlientPatch.LaunchClient(a.gwpath,
                                                                         " -email \"" + a.email + "\" -password \"" + a.password + "\" -character \"" +
                                                                         a.character + "\" " + a.extraargs, a.datfix, false, a.elevated, a.mods);

                            //uModTexClient client = new uModTexClient();
                            //TexBundle bundle = new TexBundle("C:\\Users\\m\\OneDrive\\Desktop\\programs\\gw1\\Minimalus_Dub.tpf");
                            //client.AddBundle(bundle);

                            uint timelock = 0;
                            while (m.process.MainWindowHandle == IntPtr.Zero)
                            {
                                Thread.Sleep(1000);
                                timelock += 1;
                                if (timelock <= 10)
                                {
                                    continue;
                                }
                                ok = false;
                                break;
                            }

                            if (!ok)
                            {
                                continue;
                            }
                            a.process = m;

                            mf.SetActive(i, true);
                            timelock = 0;
                            GWMem.FindAddressesIfNeeded(m);
                            while (m.Read <ushort>(GWMem.CharnamePtr) == 0 && timelock < 60)
                            {
                                Thread.Sleep(1000);
                                timelock += 1;
                            }
                            Thread.Sleep(sleep);
                            sleep += 5000;
                        }

                        mutex.WaitOne();

                        for (var i = 0; i < accounts.Length; ++i)
                        {
                            if (!accounts[i].active)
                            {
                                continue;
                            }
                            if (accounts[i].process.process.HasExited)
                            {
                                mf.SetActive(i, false);
                            }
                        }

                        mutex.ReleaseMutex();

                        Thread.Sleep(150);
                    }
                });
                Application.Run(mf);

                mainthread.Abort();
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: bsmr/gwlauncher
        static void Main()
        {
            Process[] p = Process.GetProcessesByName("GW Launcher");
            // if (p.Length > 0)
            // {
            //     SetForegroundWindow(p[0].MainWindowHandle);
            //    return;
            // }

            StreamReader file;

            try
            {
                file = new StreamReader("Accounts.json");
            }
            catch (FileNotFoundException)
            {
                StreamWriter writerfile = File.CreateText("Accounts.json");
                writerfile.Write("[]");
                writerfile.Close();
                file = new StreamReader("Accounts.json");
            }

            JsonTextReader reader     = new JsonTextReader(file);
            JsonSerializer serializer = new JsonSerializer();

            accounts = serializer.Deserialize <Account[]>(reader);
            for (int i = 0; i < accounts.Length; ++i)
            {
                accounts[i].active = false;
            }
            file.Close();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            MainForm mf = new MainForm();

            mf.Location = new System.Drawing.Point(-1000, -1000);

            mainthread = new Thread(() =>
            {
                bool main_closed = false;
                mf.FormClosed   += (s, a) => { main_closed = true; };
                while (!main_closed)
                {
                    int sleep = 5000;
                    while (mf.needtolaunch.Count > 0)
                    {
                        int i        = mf.needtolaunch.Dequeue();
                        Account a    = accounts[i];
                        GWCAMemory m = MulticlientPatch.LaunchClient(a.gwpath, " -email \"" + a.email + "\" -password \"" + a.password + "\" -character \"" + a.character + "\" " + a.extraargs, a.datfix);
                        GWMem.FindAddressesIfNeeded(m);
                        a.process = m;
                        m.WriteWString(GWMem.WinTitle, a.character + '\0');

                        mf.SetActive(i, true);

                        while (m.Read <ushort>(GWMem.CharnamePtr) == 0)
                        {
                            Thread.Sleep(1000);
                        }

                        Thread.Sleep(sleep);
                        sleep += 5000;
                    }


                    mutex.WaitOne();

                    for (int i = 0; i < accounts.Length; ++i)
                    {
                        if (accounts[i].active)
                        {
                            if (accounts[i].process.process.HasExited)
                            {
                                mf.SetActive(i, false);
                            }
                        }
                    }

                    mutex.ReleaseMutex();

                    Thread.Sleep(150);
                }
            });
            Application.Run(mf);

            mainthread.Abort();
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: matlink/gwlauncher
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (Mutex.TryOpenExisting(gwlMutexName, out gwlMutex))
            {
                return;
            }
            else
            {
                gwlMutex = new Mutex(true, gwlMutexName);
            }

            settings = GlobalSettings.Load();


            accounts = new AccountManager("Accounts.json");
            for (int i = 0; i < accounts.Length; ++i)
            {
                accounts[i].active = false;
            }

            MainForm mf = new MainForm();

            mf.Location     = new System.Drawing.Point(-1000, -1000);
            mf.FormClosing += (object sender, FormClosingEventArgs e) =>
            {
                Program.settings.Save();
            };

            mainthread = new Thread(() =>
            {
                bool main_closed = false;
                mf.FormClosed   += (s, a) => { main_closed = true; };
                while (!main_closed)
                {
                    int sleep = 5000;
                    while (mf.needtolaunch.Count > 0)
                    {
                        int i        = mf.needtolaunch.Dequeue();
                        bool ok      = true;
                        Account a    = accounts[i];
                        GWCAMemory m = MulticlientPatch.LaunchClient(a.gwpath, " -email \"" + a.email + "\" -password \"" + a.password + "\" -character \"" + a.character + "\" " + a.extraargs, a.datfix, false, a.mods);

                        uint timelock = 0;
                        while (ok && m.process.MainWindowHandle == IntPtr.Zero)
                        {
                            Thread.Sleep(1000);
                            timelock += 1;
                            if (timelock > 10)
                            {
                                ok = false;
                                break;
                            }
                        }
                        if (!ok)
                        {
                            continue;
                        }
                        a.process = m;
                        //m.WriteWString(GWMem.WinTitle, a.character + '\0');

                        mf.SetActive(i, true);
                        timelock = 0;
                        GWMem.FindAddressesIfNeeded(m);
                        while (ok && m.Read <ushort>(GWMem.CharnamePtr) == 0 && timelock < 60)
                        {
                            Thread.Sleep(1000);
                            timelock += 1;
                        }

                        Thread.Sleep(sleep);
                        sleep += 5000;
                    }


                    mutex.WaitOne();

                    for (int i = 0; i < accounts.Length; ++i)
                    {
                        if (accounts[i].active)
                        {
                            if (accounts[i].process.process.HasExited)
                            {
                                mf.SetActive(i, false);
                            }
                        }
                    }

                    mutex.ReleaseMutex();

                    Thread.Sleep(150);
                }
            });
            Application.Run(mf);

            mainthread.Abort();
        }
コード例 #5
0
        static void Main()
        {
            if (Mutex.TryOpenExisting(gwlMutexName, out gwlMutex))
            {
                return;
            }
            else
            {
                gwlMutex = new Mutex(true, gwlMutexName);
            }


            accounts = new AccountManager("Accounts.json");
            for (int i = 0; i < accounts.Length; ++i)
            {
                accounts[i].active = false;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            MainForm mf = new MainForm();

            mf.Location = new System.Drawing.Point(-1000, -1000);

            mainthread = new Thread(() =>
            {
                bool main_closed = false;
                mf.FormClosed   += (s, a) => { main_closed = true; };
                while (!main_closed)
                {
                    int sleep = 5000;
                    while (mf.needtolaunch.Count > 0)
                    {
                        int i        = mf.needtolaunch.Dequeue();
                        Account a    = accounts[i];
                        GWCAMemory m = MulticlientPatch.LaunchClient(a.gwpath, " -email \"" + a.email + "\" -password \"" + a.password + "\" -character \"" + a.character + "\" " + a.extraargs, a.datfix, false, a.mods);
                        GWMem.FindAddressesIfNeeded(m);
                        a.process = m;
                        m.WriteWString(GWMem.WinTitle, a.character + '\0');

                        mf.SetActive(i, true);

                        while (m.Read <ushort>(GWMem.CharnamePtr) == 0)
                        {
                            Thread.Sleep(1000);
                        }

                        Thread.Sleep(sleep);
                        sleep += 5000;
                    }


                    mutex.WaitOne();

                    for (int i = 0; i < accounts.Length; ++i)
                    {
                        if (accounts[i].active)
                        {
                            if (accounts[i].process.process.HasExited)
                            {
                                mf.SetActive(i, false);
                            }
                        }
                    }

                    mutex.ReleaseMutex();

                    Thread.Sleep(150);
                }
            });
            Application.Run(mf);

            mainthread.Abort();
        }