elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Únete al Grupo Steam elhacker.NET


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  AutoLogin en C#
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: AutoLogin en C#  (Leído 1,399 veces)
minatohd

Desconectado Desconectado

Mensajes: 2


Ver Perfil
AutoLogin en C#
« en: 24 Febrero 2015, 12:23 pm »

Hola!

Estoy haciendo un bot que se logee solo a un juego.

Lo que hago es guardar el boton del login en una imagen BMP "bmpLogin.bmp", despues hago una captura de pantalla, localizo el boton dentro de esa captura de pantalla, saco X e Y, ubico el puntero del raton encima del boton. ¡Hasta ahi todo bien! pero luego el click no me lo realiza, no se si es por que es una aplicacion externa a mi aplicacion o no entiendo...

Os dejo mi codigo y a ver si podeis ayudarme, gracias.

Código:


namespace AutoLogin
{
    public partial class frmMain : Form
    {
        [DllImport("user32.dll")]
        static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData,
          int dwExtraInfo);

        public enum MouseEventFlags : uint
        {
            LEFTDOWN = 0x00000002,
            LEFTUP = 0x00000004,
            MIDDLEDOWN = 0x00000020,
            MIDDLEUP = 0x00000040,
            MOVE = 0x00000001,
            ABSOLUTE = 0x00008000,
            RIGHTDOWN = 0x00000008,
            RIGHTUP = 0x00000010,
            WHEEL = 0x00000800,
            XDOWN = 0x00000080,
            XUP = 0x00000100
        }

        public frmMain()
        {
            InitializeComponent();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            Bitmap bmpScreenshot = Screenshot();
            this.BackgroundImage = bmpScreenshot;
            Point location;
            bool success = FindBitmap(Properties.Resources.bmpLogin, bmpScreenshot, out location);
            if (success == false)
            {
                MessageBox.Show("¡No encuentro el boton!");
                return;
            }
            Cursor.Position = location;
            MouseClick();
        }

        private void MouseClick()
        {
            mouse_event((uint)MouseEventFlags.LEFTDOWN, 0, 0, 0, 0);
            Thread.Sleep((new Random()).Next(20, 30));
            mouse_event((uint)MouseEventFlags.LEFTUP, 0, 0, 0, 0);
        }

        private Bitmap Screenshot()
        {
            Bitmap bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
            Graphics g = Graphics.FromImage(bmpScreenshot);
            g.CopyFromScreen(0, 0, 0, 0, Screen.PrimaryScreen.Bounds.Size);
            return bmpScreenshot;
        }


        private bool FindBitmap(Bitmap bmpNeedle, Bitmap bmpHaystack, out Point location)
        {
            for(int outerX = 0; outerX < bmpHaystack.Width - bmpNeedle.Width; outerX++)
            {
                for (int outerY = 0; outerY < bmpHaystack.Height - bmpNeedle.Height; outerY++)
                {
                    for (int innerX = 0; innerX < bmpNeedle.Width; innerX++)
                    {
                        for (int innerY = 0; innerY < bmpNeedle.Height; innerY++)
                        {
                            Color cNeedle = bmpNeedle.GetPixel(innerX, innerY);
                            Color cHaystack = bmpHaystack.GetPixel(innerX + outerX, innerY + outerY);

                            if (cNeedle.R != cHaystack.R || cNeedle.G != cHaystack.G || cNeedle.B != cHaystack.B)
                            {
                                goto notFound;
                            }
                        }
                    }
                    location = new Point(outerX, outerY);
                    return true;
                notFound:
                    continue;
                }
            }
            location = Point.Empty;
            return false;
        }

        private void frmMain_Load(object sender, EventArgs e)
        {

        }
    }
}



En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
como puedo hacer un autologin para una web mediate vb
Programación Visual Basic
arnoldz 2 2,730 Último mensaje 23 Diciembre 2008, 02:45 am
por arnoldz
ayuda con AUTOLOGIN DOBLE VALOR (SOLO PARA LOBOS EN VB)
Programación Visual Basic
arnoldz 2 2,439 Último mensaje 23 Diciembre 2008, 12:23 pm
por arnoldz
[Python] Autologin web (interactivo)
Scripting
ferminako 4 4,788 Último mensaje 22 Noviembre 2012, 11:23 am
por Eleкtro
Recuperar sesion Lubuntu en la 12.10 con autologin (SOLUCIONADO)
GNU/Linux
adgellida 0 2,897 Último mensaje 12 Noviembre 2012, 16:57 pm
por adgellida
Autologin Wifi web « 1 2 »
Redes
alucine 12 8,022 Último mensaje 7 Noviembre 2016, 16:22 pm
por SCORY
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines