/// <summary> /// Get a list of all the open clients of certain version. Class method. /// </summary> /// <returns></returns> public static List <Client> GetClients(string version, bool offline) { List <Client> clients = new List <Client>(); Client client = null; foreach (Process process in Process.GetProcesses()) { StringBuilder classname = new StringBuilder(); Util.WinAPI.GetClassName(process.MainWindowHandle, classname, 12); if (classname.ToString().Equals("DirectX5Wnd", StringComparison.CurrentCultureIgnoreCase)) { if (version == null) { client = new Client(process); if (!offline || !client.LoggedIn()) { clients.Add(client); } } else if (process.MainModule.FileVersionInfo.FileVersion == version) { clients.Add(new Client(process)); if (!offline || !client.LoggedIn()) { clients.Add(client); } } } } return(clients); }
public HookProxy(Client client) { this.client = client; serverRecvMsg = new NetworkMessage(client); serverSendMsg = new NetworkMessage(client); clientRecvMsg = new NetworkMessage(client); clientSendMsg = new NetworkMessage(client); if (client.Dll.Pipe == null) { client.Dll.InitializePipe(); client.Dll.PipeIsReady.WaitOne(); } client.Dll.Pipe.OnSocketRecv += new Pipe.PipeListener(Pipe_OnSocketRecv); client.Dll.Pipe.OnSocketSend += new Pipe.PipeListener(Pipe_OnSocketSend); if (client.LoggedIn()) protocol = Protocol.World; else protocol = Protocol.None; }
/// <summary> /// Get a list of all the open clients of certain version. Class method. /// </summary> /// <returns></returns> public static List<Client> GetClients(string version, bool offline) { List<Client> clients = new List<Client>(); Client client = null; foreach (Process process in Process.GetProcesses()) { StringBuilder classname = new StringBuilder(); Util.WinAPI.GetClassName(process.MainWindowHandle, classname, 12); if (classname.ToString().Equals("DirectX5Wnd", StringComparison.CurrentCultureIgnoreCase)) { if (version == null) { client = new Client(process); if (!offline || !client.LoggedIn()) clients.Add(client); } else if (process.MainModule.FileVersionInfo.FileVersion == version) { clients.Add(new Client(process)); if (!offline || !client.LoggedIn()) clients.Add(client); } } } return clients; }
public bool Login(string login, string password, string charName) { //if the player is logged or the window is minimazed return false. if (client.Window.IsMinimized()) { if (Report != null) { Report.Invoke(State.Minimized); } return(false); } else if (client.LoggedIn()) { if (client.GetPlayer().HasFlag(Pokemon.Constants.Flag.InBattle)) { if (Report != null) { Report.Invoke(State.InBattle); } return(false); } //send CTRL+G, or however it is done //TO DO /* * client.Input.SendMessage(Hooks.WM_KEYDOWN, (int)Keys.Control, 0); * client.Input.SendMessage(Hooks.WM_KEYDOWN, (int)Keys.G, 0); * client.Input.SendMessage(Hooks.WM_CHAR, (int)Keys.G, 0); * client.Input.SendMessage(Hooks.WM_KEYUP, (int)Keys.G, 0); * client.Input.SendMessage(Hooks.WM_KEYUP, (int)Keys.Control, 0); * Thread.Sleep(300);*/ return(false); } else { //assure the screen is clean, no dialog open client.Input.SendKey(Keys.Escape); client.Input.SendKey(Keys.Escape); if (Report != null) { Report.Invoke(State.DialogsCleaned); } //reset the selected char value.. client.Memory.WriteUInt32(Pokemon.Addresses.Client.LoginSelectedChar, 0); if (Report != null) { Report.Invoke(State.ResetSelectedCharValue); } //reset the char count value.. client.Memory.WriteInt32(Pokemon.Addresses.Client.LoginCharListLength, 0); if (Report != null) { Report.Invoke(State.ResetSelectedCharCount); } //click the enter the game button client.Input.Click(120, client.Window.Size().Height - 250); if (Report != null) { Report.Invoke(State.ClickEnterButton); } //wait the dialog open int waitTime = 2000; while (!client.Window.IsDialogOpen() && client.Window.GetDialogCaption() != "Enter Game") { Thread.Sleep(100); waitTime -= 100; if (waitTime <= 0) { if (Report != null) { Report.Invoke(State.LoginDialogDidntOpen); } return(false); } } if (Report != null) { Report.Invoke(State.LoginDialogOpened); } //now we have to send the login and the password client.Input.SendString(login); if (Report != null) { Report.Invoke(State.InputAccName); } //press tab client.Input.SendKey(Keys.Tab); if (Report != null) { Report.Invoke(State.PressTab); } //put the pass client.Input.SendString(password); if (Report != null) { Report.Invoke(State.InputPassword); } //press enter.. client.Input.SendKey(Keys.Enter); if (Report != null) { Report.Invoke(State.PressEnter); } //wait for the charlist dialog waitTime = 4000; while (CharListCount == 0) { Thread.Sleep(100); waitTime -= 100; if (waitTime <= 0) { if (Report != null) { Report.Invoke(State.CharListNotReceived); } return(false); } } if (Report != null) { Report.Invoke(State.CharListReceived); } waitTime = 1000; while (client.Window.GetDialogCaption() == "Connecting") { Thread.Sleep(100); waitTime -= 100; if (waitTime <= 0) { if (Report != null) { Report.Invoke(State.ConnectingDialogNotGone); } return(false); } } if (Report != null) { Report.Invoke(State.ConnectingDialogGone); } Thread.Sleep(100); // Check if there is a message of the day if (client.Window.GetDialogCaption() != "Select Character") { client.Input.SendKey(Keys.Enter); Thread.Sleep(100); if (Report != null) { Report.Invoke(State.Motd); } } } //now we loop at the charlist to find the selected char.. foreach (var ch in CharacterList) { Thread.Sleep(100); //make sure the client process the msg //we start at position 0 if (string.Compare(ch.CharName, charName, true) == 0) { //we found the char //lets press the entrer key client.Input.SendKey(Keys.Enter); if (Report != null) { Report.Invoke(State.SelectedCharFound); } return(true); } //move to the next char client.Input.SendKey(Keys.Down); if (Report != null) { Report.Invoke(State.GoToNextChar); } } //char not found. if (Report != null) { Report.Invoke(State.SelectedCharNotFound); } return(false); }