private bool GetAutoProgressIsActive() { //bitblt the screen Bitmap bmp = GetWindowSnapshot.GetSnapshot(); if (bmp == null) { return(true);//don't want to do anything. } //0,255,0 (pure green) is used to indicate autoprogress is ON //255,255,255 (pure white) is used to indicate autoprogress is OFF, but ALSO on the next/prev 5 levels button //Not seeing pure green used elsewhere, if there is pure green on the top right corner, it's in Autoprogress (assumption). //empirically looking, it seems that the item we want is in the right 5% of the screen, and the top 20% int left = (int)(bmp.Width * .95); int top = 0; int width = (int)(bmp.Width - left); int height = (int)(bmp.Height * .2); bool isAutoProgress = GetWindowSnapshot.PureGreenInSubRectangle(bmp, top, left, height, width); //pull these numbers from the snapshot file that can be saved in GetSnapshot bmp.Dispose(); return(isAutoProgress); }
private void Wokaholic_DoWork(object sender, DoWorkEventArgs e) { while (!workaholic.CancellationPending) { bool autoProgressIsActive = GetAutoProgressIsActive(); if (autoProgressIsActive) { Console.WriteLine("Autoprogress is active"); _autoProgressLastActive = DateTime.UtcNow; } else { Console.WriteLine("Autoprogress NOT active"); } //G is toggle auto-progress. Detect if we've been off autoprogress for the last 5 minutes. If not, toggle on. That should give some time to gain money/clvls before trying to go forward again. if (chkAutoprogress.Checked && !autoProgressIsActive && DateTime.UtcNow.Subtract(_autoProgressLastActive).TotalMinutes > (int)nudReAutoProgress.Value) { Console.WriteLine("Toggling Autoprogress, should now be ON"); SendKey.Send("g"); } IntPtr myWindow = SendKey.SetWindow();//duplicative with stuff done in GetAutoProgressIsActive, but that's fine. if (chkSlot1.Checked) { SendKey.Send("{F1}"); } if (chkSlot2.Checked) { SendKey.Send("{F2}"); } if (chkSlot3.Checked) { SendKey.Send("{F3}"); } if (chkSlot4.Checked) { SendKey.Send("{F4}"); } if (chkSlot5.Checked) { SendKey.Send("{F5}"); } if (chkSlot6.Checked) { SendKey.Send("{F6}"); } if (chkSlot7.Checked) { SendKey.Send("{F7}"); } if (chkSlot8.Checked) { SendKey.Send("{F8}"); } if (chkSlot9.Checked) { SendKey.Send("{F9}"); } if (chkSlot10.Checked) { SendKey.Send("{F10}"); } if (chkSlot11.Checked) { SendKey.Send("{F11}"); } if (chkSlot12.Checked) { SendKey.Send("{F12}"); } SendKey.ReturnWindow(myWindow);//duplicative with below, but that's fine. GetWindowSnapshot.ReturnToPreviousWindowstate(); Thread.Sleep((int)nudCycleTime.Value * 1000); } }