Beispiel #1
0
 private void UI_Shown(object sender, EventArgs e)
 {
     if (!WinApi.IsIconic(Client.Tibia.MainWindowHandle)) //IsIconic = minimized
     {
         WinApi.RECT rectTibiaPos = new WinApi.RECT();
         WinApi.GetWindowRect(Client.Tibia.MainWindowHandle, out rectTibiaPos);
         WinApi.RECT rectClient = new WinApi.RECT();
         WinApi.GetClientRect(Client.Tibia.MainWindowHandle, out rectClient);
         this.Location = new Point(rectTibiaPos.right - rectClient.right, rectTibiaPos.bottom - rectClient.bottom);
     }
     if (Proxy.doAutoPlayback || Proxy.doAutoRecord)
     {
         Thread t = new Thread(ThreadAutomaticPlaybackRecord);
         t.Start();
     }
     this.Width = 105; // for some reason the width f***s up in the designer
     FormXDefault = this.Width;
     FormYDefault = this.Height;
 }
Beispiel #2
0
        private void HUD_Shown(object sender, EventArgs e)
        {
            const int GWL_EXSTYLE = -20;
            const int WS_EX_TRANSPARENT = 0x20;

            int exstyle = WinApi.GetWindowLong(formHUD.Handle, GWL_EXSTYLE);
            exstyle |= WS_EX_TRANSPARENT;
            WinApi.SetWindowLong(formHUD.Handle, GWL_EXSTYLE, exstyle);

            /*IntPtr hwndf = formHUD.Handle;
            IntPtr hwndParent = IntPtr.Zero;
            WinApi.SetParent(hwndf, hwndParent);*/

            //this.TopMost = true;
            hasHUDShown = true;

            formHUD.ShowInTaskbar = false;
            formHUD.ShowIcon = false;
            formHUD.TopMost = true;
            formHUD.Show();
            formHUD.FormBorderStyle = FormBorderStyle.None;
            formHUD.TransparencyKey = formHUD.BackColor;
            WinApi.RECT rect = new WinApi.RECT();
            WinApi.GetClientRect(Client.Tibia.MainWindowHandle, out rect);
            formHUD.Size = new Size(rect.right, rect.bottom);
            WinApi.GetWindowRect(Client.Tibia.MainWindowHandle, out rect);
            formHUD.Location = new Point(rect.left, rect.top);
            timerHUD.Start();
        }
Beispiel #3
0
        private void ThreadHUD()
        {
            try
            {
                while (timerHUD.Enabled)
                {
                    if (!Client.Tibia.HasExited && WinApi.GetForegroundWindow() == Client.Tibia.MainWindowHandle)
                    {
                        if (!formHUD.Visible)
                        {
                            formHUD.Show();
                        }
                        if (Memory.ReadByte(Addresses.Client.Connection) == 8)
                        {
                            try
                            {
                                string firstLoginServer = Client.Misc.GetLoginServers()[0];
                                if (firstLoginServer != null)
                                {
                                    if (firstLoginServer == "127.0.0.1" && Proxy.characterList.Count > 0) // we are using tibiacam
                                    {
                                        string IP = Proxy.characterList[Memory.ReadByte(Addresses.Charlist.SelectedIndex)].IP;
                                        Utils.Pinger.Ping(IP);
                                    }
                                    else
                                    {
                                        string IP = CharacterList.Players[Memory.ReadByte(Addresses.Charlist.SelectedIndex)].IP;
                                        Utils.Pinger.Ping(IP);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {

                            }
                        }
                        WinApi.RECT rect = new WinApi.RECT();
                        WinApi.GetWindowRect(Client.Tibia.MainWindowHandle, out rect);
                        if (!formHUD.Size.Equals(new Size(rect.right - rect.left, rect.bottom - rect.top)) ||
                            !formHUD.Location.Equals(new Point(rect.left, rect.top)))
                        {
                            formHUD.Size = new Size(rect.right - rect.left, rect.bottom - rect.top);
                            formHUD.Location = new Point(rect.left, rect.top);
                        }
                        if (listboxHUDLabels.Items.Count > 0)
                        {
                            foreach (Label formLabel in formHUD.Controls)
                            {
                                string labelName = formLabel.Name;
                                for (int i = 0; i < listboxHUDLabels.Items.Count; i++)
                                {
                                    string text = listboxHUDLabels.Items[i].ToString();
                                    string ID = text.Substring(0, text.IndexOf(':'));
                                    if (ID == formLabel.Name)
                                    {
                                        string Text = text.Substring(text.IndexOf(':') + 1);
                                        // to be replaced with a stringbuilder
                                        formLabel.Text = Text.Replace("$experience", Memory.ReadUInt(Addresses.Player.Exp).ToString())
                                                                   .Replace("$exptnl", Utils.ExperienceCounter.GetExperienceTNL().ToString())
                                                                   .Replace("$expgained", Utils.ExperienceCounter.GetGainedExperience().ToString())
                                                                   .Replace("$exph", Utils.ExperienceCounter.GetExperiencePerHour().ToString())
                                                                   .Replace("$lvlperctnl", Utils.ExperienceCounter.GetLevelPercentTNL().ToString())
                                                                   .Replace("$lvlperch", Utils.ExperienceCounter.GetLevelPercentPerHour().ToString())
                                                                   .Replace("$lvlpercgained", Utils.ExperienceCounter.GetGainedLevelPercent().ToString())
                                                                   .Replace("$lvltimetnl", Utils.ExperienceCounter.GetTimeLeftTNL())
                                                                   .Replace("$axeskill", Memory.ReadUShort(Addresses.Player.Axe).ToString())
                                                                   .Replace("$axegained", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Axe).PercentGained.ToString())
                                                                   .Replace("$axepercent", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Axe).PercentLeft.ToString())
                                                                   .Replace("$axeperch", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Axe).PercentPerHour.ToString())
                                                                   .Replace("$axetimetnl", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Axe).TimeLeft)
                                                                   .Replace("$clubskill", Memory.ReadUShort(Addresses.Player.Club).ToString())
                                                                   .Replace("$clubgained", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Axe).PercentGained.ToString())
                                                                   .Replace("$clubpercent", (100 - Memory.ReadUShort(Addresses.Player.ClubPercent)).ToString())
                                                                   .Replace("$clubperch", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Club).PercentPerHour.ToString())
                                                                   .Replace("$clubtimetnl", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Club).TimeLeft)
                                                                   .Replace("$swordskill", Memory.ReadUShort(Addresses.Player.Sword).ToString())
                                                                   .Replace("$swordgained", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Sword).PercentGained.ToString())
                                                                   .Replace("$swordpercent", (100 - Memory.ReadUShort(Addresses.Player.SwordPercent)).ToString())
                                                                   .Replace("$swordperch", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Sword).PercentPerHour.ToString())
                                                                   .Replace("$swordtimetnl", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Sword).TimeLeft)
                                                                   .Replace("$distskill", Memory.ReadUShort(Addresses.Player.Distance).ToString())
                                                                   .Replace("$distgained", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Distance).PercentGained.ToString())
                                                                   .Replace("$distpercent", (100 - Memory.ReadUShort(Addresses.Player.DistancePercent)).ToString())
                                                                   .Replace("$distperch", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Distance).PercentPerHour.ToString())
                                                                   .Replace("$disttimetnl", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Distance).TimeLeft)
                                                                   .Replace("$fistskill", Memory.ReadUShort(Addresses.Player.Fist).ToString())
                                                                   .Replace("$fistgained", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Fist).PercentGained.ToString())
                                                                   .Replace("$fistpercent", (100 - Memory.ReadUShort(Addresses.Player.FistPercent)).ToString())
                                                                   .Replace("$fistperch", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Fist).PercentPerHour.ToString())
                                                                   .Replace("$fisttimetnl", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Fist).TimeLeft)
                                                                   .Replace("$mlvlskill", Memory.ReadUShort(Addresses.Player.MagicLevel).ToString())
                                                                   .Replace("$mlvlgained", Utils.SkillCounter.GetSkillInfo(Enums.Skill.MagicLevel).PercentGained.ToString())
                                                                   .Replace("$mlvlpercent", (100 - Memory.ReadUShort(Addresses.Player.MagicLevelPercent)).ToString())
                                                                   .Replace("$mlvlperch", Utils.SkillCounter.GetSkillInfo(Enums.Skill.MagicLevel).PercentPerHour.ToString())
                                                                   .Replace("$mlvltimetnl", Utils.SkillCounter.GetSkillInfo(Enums.Skill.MagicLevel).TimeLeft)
                                                                   .Replace("$shieldingskill", Memory.ReadUShort(Addresses.Player.Shielding).ToString())
                                                                   .Replace("$shieldinggained", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Shielding).PercentGained.ToString())
                                                                   .Replace("$shieldingpercent", (100 - Memory.ReadUShort(Addresses.Player.ShieldingPercent)).ToString())
                                                                   .Replace("$shieldingperch", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Shielding).PercentPerHour.ToString())
                                                                   .Replace("$shieldingtimetnl", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Shielding).TimeLeft)
                                                                   .Replace("$fishingskill", Memory.ReadUShort(Addresses.Player.Fishing).ToString())
                                                                   .Replace("$fishinggained", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Fishing).PercentGained.ToString())
                                                                   .Replace("$fishingpercent", (100 - Memory.ReadUShort(Addresses.Player.FishingPercent)).ToString())
                                                                   .Replace("$fishingperch", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Fishing).PercentPerHour.ToString())
                                                                   .Replace("$fishingtimetnl", Utils.SkillCounter.GetSkillInfo(Enums.Skill.Fishing).TimeLeft)
                                                                   .Replace("$timeactiveexp", Utils.ExperienceCounter.GetTotalRunningTimeString())
                                                                   .Replace("$timeactiveskill", Utils.SkillCounter.GetTotalRunningTimeString())
                                                                   .Replace("$tibiastarttime", Client.Tibia.StartTime.ToString())
                                                                   .Replace("$fps", Client.Misc.FPS.ToString())
                                                                   .Replace("$ping", Utils.Pinger.LastRoundtripTime.ToString() + "ms");

                                        break;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (formHUD.Visible)
                        {
                            formHUD.Hide();
                        }
                    }

                    Thread.Sleep(1000);
                }
            }
            catch (Exception ex)
            {
                Utils.ExceptionHandler(ex);
            }
        }
Beispiel #4
0
            /// <summary>
            /// Logs in using PostMessage.
            /// </summary>
            /// <param name="accountNumber"></param>
            /// <param name="password"></param>
            /// <param name="character"></param>
            internal static void Login(uint accountNumber, string password, string character)
            {
                if (Memory.ReadByte(Addresses.Client.Connection) != 0)
                {
                    return;
                }
                while (WinApi.IsIconic(Client.Tibia.MainWindowHandle))
                {
                    WinApi.ShowWindow(Client.Tibia.MainWindowHandle, WinApi.SW_SHOW);
                    System.Threading.Thread.Sleep(500);
                }
                while (Memory.ReadByte(Addresses.Client.DialogOpen) != 0)
                {
                    Utils.SendTibiaKeys("escape");
                    System.Threading.Thread.Sleep(300);
                }
                Memory.WriteByte(Addresses.Charlist.NumberOfCharacters, 0);
                WinApi.RECT rect            = Client.ClientRECT;
                bool        inputBoxFocused = false;

                while (!inputBoxFocused)
                {
                    rect = Client.ClientRECT;
                    Utils.SendMouseClick(120, rect.bottom - 215);
                    for (int i = 0; i < 5; i++)
                    {
                        if (Memory.ReadByte(Addresses.Client.DialogOpen) > 0 &&
                            Client.Misc.DialogTitle == "Enter Game")
                        {
                            inputBoxFocused = true;
                            break;
                        }
                        System.Threading.Thread.Sleep(100);
                    }
                }
                inputBoxFocused = false;
                while (!inputBoxFocused)
                {
                    Utils.SendTibiaString(accountNumber.ToString());
                    System.Threading.Thread.Sleep(100);
                    Utils.SendTibiaKey(Keys.Tab);
                    System.Threading.Thread.Sleep(100);
                    Utils.SendTibiaString(password);
                    System.Threading.Thread.Sleep(100);
                    Utils.SendTibiaKeys("enter");
                    for (int i = 0; i < 10; i++)
                    {
                        if (Memory.ReadByte(Addresses.Client.DialogOpen) > 0 &&
                            Client.Misc.DialogTitle == "Select Character" ||
                            Client.Misc.DialogTitle == "Connecting")
                        {
                            inputBoxFocused = true;
                            break;
                        }
                        System.Threading.Thread.Sleep(100);
                    }
                }
                while (Client.Misc.DialogTitle == "Connecting")
                {
                    System.Threading.Thread.Sleep(100);
                }
                System.Threading.Thread.Sleep(1000);
                if (Client.Misc.DialogTitle.StartsWith("Message"))
                {
                    Utils.SendTibiaKeys("enter");
                    System.Threading.Thread.Sleep(1000);
                }
                if (Client.Misc.DialogTitle == "Select Character")
                {
                    foreach (Objects.CharacterList.Player _player in Objects.CharacterList.GetPlayers())
                    {
                        if (_player.Name.ToLower() == character.ToLower())
                        {
                            Utils.SendTibiaKeys("enter");
                            break;
                        }
                        System.Threading.Thread.Sleep(100);
                        Utils.SendTibiaKeys("down");
                    }
                }
            }