Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. using MySql.Data.MySqlClient;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Diagnostics;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Runtime.InteropServices;
  10. using System.Text;
  11. using System.Threading;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14.  
  15. namespace WindowsFormsApplication3
  16. {
  17. public partial class Form1 : Form
  18. {
  19. int kol;
  20. public Form1()
  21. {
  22. SetForegroundWindow(Process.GetProcessesByName("chrome")[0].MainWindowHandle);
  23.  
  24. InitializeComponent();
  25. Task.Delay(5000).Wait();
  26. string serverIp = "localhost";
  27. string username = "root";
  28. string password = "salami";
  29. string databaseName = "league";
  30.  
  31. MySqlConnection con = new MySqlConnection(string.Format("server={0};uid={1};pwd={2};database={3};", serverIp, username, password, databaseName));
  32. con.Open();
  33. MySqlCommand cmd = new MySqlCommand();
  34. cmd.Connection = con;
  35. cmd.CommandText = "SELECT * FROM league;";
  36. MySqlDataReader reader = cmd.ExecuteReader();
  37. reader.Read();
  38.  
  39. while (reader.Read())
  40. {
  41. for (int i = 0; i < reader.FieldCount; i++)
  42. {
  43. kol++;
  44. addFriend(reader.GetString(i), kol.ToString());
  45. Thread.Sleep(2); //ms
  46. }
  47. }
  48. }
  49. [DllImport("user32.dll")]
  50. [return: MarshalAs(UnmanagedType.Bool)]
  51. static extern bool SetForegroundWindow(IntPtr hWnd);
  52.  
  53. [DllImport("user32.dll")]
  54. private static extern IntPtr GetForegroundWindow();
  55.  
  56. [System.Runtime.InteropServices.DllImport("user32.dll")]
  57. static extern bool SetCursorPos(int x, int y);
  58.  
  59. [System.Runtime.InteropServices.DllImport("user32.dll")]
  60. public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
  61.  
  62. public const int MOUSEEVENTF_LEFTDOWN = 0x02;
  63. public const int MOUSEEVENTF_LEFTUP = 0x04;
  64.  
  65. //This simulates a left mouse click
  66. public static void LeftMouseClick(int xpos, int ypos)
  67. {
  68. SetCursorPos(xpos, ypos);
  69. mouse_event(MOUSEEVENTF_LEFTDOWN, xpos, ypos, 0, 0);
  70. mouse_event(MOUSEEVENTF_LEFTUP, xpos, ypos, 0, 0);
  71. }
  72. private void addFriend(string name, string i)
  73. {
  74.  
  75. Task.Delay12).Wait();
  76. SendKeys.SendWait(" [");
  77. SendKeys.SendWait(i);
  78. SendKeys.SendWait( "] ");
  79. SendKeys.SendWait(name.ToString());
  80. Task.Delay(1).Wait();
  81. SendKeys.SendWait("{ENTER}");
  82.  
  83. }
  84. private void Form1_Load(object sender, EventArgs e)
  85. {
  86.  
  87. }
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement