private void RunBot_Work(Object sender, DoWorkEventArgs e) { if (bgw.CancellationPending) { e.Cancel = true; } else if (itr < profileController.ActiveProfile.NodeList.Count) { GenericNode node = profileController.ActiveProfile.NodeList[itr]; activeNode = node; InternalNodeSettings nodeSettings = node.Settings.internalNodeSettings; InternalTimeSettings timeSettings = node.Settings.internalTimeSettings; BindingList <RecordBase> records = node.Settings.Records; Int32 runs = nodeSettings.Runs; if (nodeSettings.Enabled != CheckState.Unchecked) { while (!bgw.CancellationPending && runs-- > 0) { foreach (RecordBase record in records) { if (bgw.CancellationPending) { e.Cancel = true; return; } activeRecord = record; bgw.ReportProgress(itr * 4); if (runs > 0) { activeRepeats = runs; bgw.ReportProgress(itr * 4 + 1); } if (record.Type == RecordType.DurationRecord) { // This code allows users to stop the bot during long sleeps Int32 duration = ((DurationRecord)record).Duration, iterations = duration / DURATION_ITERATION_INTERVAL, remainder = duration % DURATION_ITERATION_INTERVAL; if (duration > DURATION_ITERATION_INTERVAL * DURATION_ITERATION_MARGIN) { for (Int32 i = 0; i < iterations; ++i) { System.Threading.Thread.Sleep(DURATION_ITERATION_INTERVAL); if (bgw.CancellationPending) { e.Cancel = true; return; } } System.Threading.Thread.Sleep(remainder); } else { System.Threading.Thread.Sleep(duration); } } else if (record.Type == RecordType.ClickRecord) { bgw.ReportProgress(itr * 4 + 2); Random rand = new Random(); Int32 mouseMoveDuration = rand.Next(1000); switch (nodeSettings.MouseSpeed) { case MouseSpeed.Slow: mouseMoveDuration = rand.Next(800, 1500); break; case MouseSpeed.Medium: mouseMoveDuration = rand.Next(500, 900); break; case MouseSpeed.Fast: mouseMoveDuration = rand.Next(100, 600); break; case MouseSpeed.Random: mouseMoveDuration = rand.Next(rand.Next(100, 600), rand.Next(700, 1500)); break; } ClickRecord clickRecord = (ClickRecord)record; // Take into account the global and local offsets (they do indeed stack) Point targetPoint = clickRecord.TargetPoint; targetPoint.X += (applicationSettings.GlobalOffsetX + nodeSettings.OffsetX); targetPoint.Y += (applicationSettings.GlobalOffsetY + nodeSettings.OffsetY); MouseController.SmoothClickMouseTo(targetPoint, mouseMoveDuration, clickRecord.SubType); } activeString = "intranode"; bgw.ReportProgress(itr * 4 + 3); Int32 sleeptimeIntranode = 0; // seconds if (applicationSettings.IntranodeForcedPauseEnabled != CheckState.Unchecked) { sleeptimeIntranode = timeSettings.ForcedPause; } if (applicationSettings.IntranodeEntropyEnabled != CheckState.Unchecked) { Random rand = new Random(); switch (timeSettings.Entropy) { case EntropyLevel.Low: sleeptimeIntranode += rand.Next(100); break; case EntropyLevel.Medium: sleeptimeIntranode += rand.Next(500); break; case EntropyLevel.High: sleeptimeIntranode += rand.Next(1000); break; } } System.Threading.Thread.Sleep(sleeptimeIntranode); } } if (bgw.CancellationPending) { e.Cancel = true; return; } activeString = "internode"; bgw.ReportProgress(itr * 4 + 3); Int32 sleeptimeInternode = 10000; // milliseconds Random randInternode = new Random(); switch (applicationSettings.InternodeEntropy) { case EntropyLevel.Low: sleeptimeInternode += randInternode.Next(10000); break; case EntropyLevel.Medium: sleeptimeInternode += randInternode.Next(30000); break; case EntropyLevel.High: sleeptimeInternode += randInternode.Next(90000); break; } System.Threading.Thread.Sleep(sleeptimeInternode); } else { bgw.ReportProgress(itr * 4 + 4); } } if (bgw.CancellationPending) { e.Cancel = true; } }
public GBGTimeSettings(GBGNodeCreateModify parent, InternalTimeSettings timeSettings) { InitializeComponent(); this.parent = parent; this.timeSettings = timeSettings; }