Autoclicker src C#


SUBMITTED BY: Payyed

DATE: Aug. 19, 2022, 4:11 a.m.

FORMAT: Text only

SIZE: 7.5 kB

HITS: 508

  1. using Dope.Theme;
  2. using Dope.utils;
  3. using Dope.utils.Hook;
  4. using Dope.views;
  5. using System;
  6. using System.Threading;
  7. using System.Windows.Forms;
  8. using static Dope.utils.Imports;
  9. namespace Dope
  10. {
  11. public partial class Main : Form
  12. {
  13. Config cfg;
  14. Form[] Views;
  15. MouseHook mousehook;
  16. KeyboardHook keyBoardHook;
  17. string hwid;
  18. public Main()
  19. {
  20. InitializeComponent();
  21. hwid = Utils.GetDiskId();
  22. cfg = new Config();
  23. InitViews();
  24. InitHook();
  25. Text = cfg.CurrentSlot.ToString();
  26. //starts threads
  27. new Thread(() => LeftClick()).Start();
  28. new Thread(() => RightClick()).Start();
  29. }
  30. //=============================================================
  31. private void Main_FormClosing(object sender, FormClosingEventArgs e)
  32. {
  33. DeleteHook();
  34. cfg.Seldestruct = true;
  35. }
  36. private void InitViews()
  37. {
  38. Views = new Form[] { new Left(cfg,this),new Jitter(cfg, this), new ClickSound(cfg, this), new Configs(), new Settings(cfg,this), new Right(cfg, this) };
  39. foreach (Form f in Views)
  40. {
  41. f.TopLevel = false;
  42. ViewsList.Controls.Add(f);
  43. f.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
  44. f.Show();
  45. }
  46. Views[0].BringToFront();
  47. }
  48. public void ChangeViews(int index)
  49. {
  50. Views[index].BringToFront();
  51. }
  52. private void side1_IndexChange(object sender, EventArgs e)
  53. {
  54. Views[side1.Index].BringToFront();
  55. }
  56. //=============================================================
  57. private void InitHook()
  58. {
  59. //create object
  60. mousehook = new MouseHook();
  61. keyBoardHook = new KeyboardHook();
  62. //register callbacks
  63. mousehook.MouseWheel += new MouseHookCallback(MouseEvent);
  64. keyBoardHook.KeyDown += new KeyboardHookCallback(KeyboardEvent);
  65. //install
  66. mousehook.Install();
  67. keyBoardHook.Install();
  68. }
  69. private void DeleteHook()
  70. {
  71. //unregister callbacks
  72. mousehook.MouseWheel -= new MouseHookCallback(MouseEvent);
  73. keyBoardHook.KeyDown -= new KeyboardHookCallback(KeyboardEvent);
  74. //ininstall
  75. mousehook.Uninstall();
  76. keyBoardHook.Uninstall();
  77. }
  78. public int getDelta(uint data)
  79. {
  80. int delta = (int)(data & 0xffff0000) >> 16;
  81. if (delta > SystemInformation.MouseWheelScrollDelta)
  82. {
  83. delta = delta - ushort.MaxValue + 1;
  84. }
  85. return delta;
  86. }
  87. public void MouseEvent(MSLLHOOKSTRUCT me)
  88. {
  89. if (getDelta(me.mouseData) > 0)
  90. {
  91. cfg.CurrentSlot--;
  92. if (cfg.CurrentSlot < 0)
  93. {
  94. cfg.CurrentSlot = 8;
  95. }
  96. }
  97. else
  98. {
  99. cfg.CurrentSlot++;
  100. if (cfg.CurrentSlot > 8)
  101. {
  102. cfg.CurrentSlot = 0;
  103. }
  104. }
  105. Text = cfg.CurrentSlot.ToString();
  106. }
  107. public void KeyboardEvent(VKeys k)
  108. {
  109. int Keypressed = (int)k;
  110. for(int i = 0; i < 9; i++)
  111. {
  112. if (Keypressed == cfg.Left_SlotList.GetKeyIndex(i) || Keypressed == cfg.right_SlotList.GetKeyIndex(i))
  113. {
  114. cfg.CurrentSlot = i;
  115. }
  116. }
  117. Text = cfg.CurrentSlot.ToString();
  118. }
  119. //=============================================================
  120. void LeftClick()
  121. {
  122. while (cfg != null || cfg.Seldestruct)
  123. {
  124. Start:
  125. if (cfg.Seldestruct) break;
  126. int delay = (int)(1000 / (Utils.rnd.Next() % (cfg.left_Max - cfg.left_Min) + cfg.left_Min) * 0.8);
  127. if (cfg.left_IA)
  128. {
  129. //je ferai un truc mieux plus tard
  130. delay = (delay * (Utils.rnd.Next(8, 15) / 10));
  131. }
  132. if (cfg.Left_Slots && !cfg.Left_SlotList.GetBoolIndex(cfg.CurrentSlot))
  133. {
  134. Thread.Sleep(1);
  135. goto Start;
  136. }
  137. if (cfg.left_focus && !Utils.MConTop())
  138. {
  139. Thread.Sleep(1);
  140. goto Start;
  141. }
  142. if (cfg.Left_Slots && !cfg.Left_SlotList.GetBoolIndex(cfg.CurrentSlot))
  143. {
  144. Thread.Sleep(1);
  145. goto Start;
  146. }
  147. if (Utils.LclickDown() && cfg.left_Click)
  148. {
  149. new Thread(() =>
  150. {
  151. if (cfg.left_Break)
  152. {
  153. Utils.SendLeftBreak();
  154. }
  155. else
  156. {
  157. Utils.SendLeftClick();
  158. }
  159. if (cfg.Sound)
  160. {
  161. Utils.ClickSound(cfg.Sound_preset);
  162. }
  163. if (cfg.Jitter)
  164. {
  165. Utils.ShakePointer(cfg.Jitter_strengh);
  166. }
  167. }).Start();
  168. }
  169. Thread.Sleep(delay);
  170. }
  171. }
  172. void RightClick()
  173. {
  174. while (cfg != null || cfg.Seldestruct)
  175. {
  176. Start:
  177. if (cfg.Seldestruct) break;
  178. int delay = (int)(1000 / (Utils.rnd.Next() % (cfg.right_Max - cfg.right_Min) + cfg.right_Min) * 0.8);
  179. if (cfg.right_IA)
  180. {
  181. //je ferai un truc mieux plus tard
  182. delay = (delay * (Utils.rnd.Next(8, 15) / 10));
  183. }
  184. if (cfg.right_focus && !Utils.MConTop())
  185. {
  186. Thread.Sleep(1);
  187. goto Start;
  188. }
  189. if (cfg.right_Slots && !cfg.right_SlotList.GetBoolIndex(cfg.CurrentSlot))
  190. {
  191. Thread.Sleep(1);
  192. goto Start;
  193. }
  194. if (Utils.RclickDown() && cfg.right_Click)
  195. {
  196. new Thread(() =>
  197. {
  198. Utils.SendRightClick();
  199. if (cfg.Sound)
  200. {
  201. Utils.ClickSound(cfg.Sound_preset);
  202. }
  203. if (cfg.Jitter)
  204. {
  205. Utils.ShakePointer(cfg.Jitter_strengh);
  206. }
  207. }).Start();
  208. }
  209. Thread.Sleep(delay);
  210. }
  211. }
  212. }
  213. }

comments powered by Disqus