Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using MySql.Data.MySqlClient;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Diagnostics;
- using System.Drawing;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsApplication3
- {
- public partial class Form1 : Form
- {
- int kol;
- public Form1()
- {
- SetForegroundWindow(Process.GetProcessesByName("chrome")[0].MainWindowHandle);
- InitializeComponent();
- Task.Delay(5000).Wait();
- string serverIp = "localhost";
- string username = "root";
- string password = "salami";
- string databaseName = "league";
- MySqlConnection con = new MySqlConnection(string.Format("server={0};uid={1};pwd={2};database={3};", serverIp, username, password, databaseName));
- con.Open();
- MySqlCommand cmd = new MySqlCommand();
- cmd.Connection = con;
- cmd.CommandText = "SELECT * FROM league;";
- MySqlDataReader reader = cmd.ExecuteReader();
- reader.Read();
- while (reader.Read())
- {
- for (int i = 0; i < reader.FieldCount; i++)
- {
- kol++;
- addFriend(reader.GetString(i), kol.ToString());
- Thread.Sleep(2); //ms
- }
- }
- }
- [DllImport("user32.dll")]
- [return: MarshalAs(UnmanagedType.Bool)]
- static extern bool SetForegroundWindow(IntPtr hWnd);
- [DllImport("user32.dll")]
- private static extern IntPtr GetForegroundWindow();
- [System.Runtime.InteropServices.DllImport("user32.dll")]
- static extern bool SetCursorPos(int x, int y);
- [System.Runtime.InteropServices.DllImport("user32.dll")]
- public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
- public const int MOUSEEVENTF_LEFTDOWN = 0x02;
- public const int MOUSEEVENTF_LEFTUP = 0x04;
- //This simulates a left mouse click
- public static void LeftMouseClick(int xpos, int ypos)
- {
- SetCursorPos(xpos, ypos);
- mouse_event(MOUSEEVENTF_LEFTDOWN, xpos, ypos, 0, 0);
- mouse_event(MOUSEEVENTF_LEFTUP, xpos, ypos, 0, 0);
- }
- private void addFriend(string name, string i)
- {
- Task.Delay12).Wait();
- SendKeys.SendWait(" [");
- SendKeys.SendWait(i);
- SendKeys.SendWait( "] ");
- SendKeys.SendWait(name.ToString());
- Task.Delay(1).Wait();
- SendKeys.SendWait("{ENTER}");
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement