private static void WaitForAbility(Character user, Keys key, bool controlKey) { user.Refresh(); //Debug.Print("Before: " + user.Status.ToString() + " " + user.IsCrafting.ToString()); Stopwatch timer = new Stopwatch(); timer.Reset(); timer.Start(); while ((user.UsingAbility) && user.IsCrafting && timer.Elapsed.Seconds < 3) { user.Refresh(); } while ((user.UsingAbility == false) && user.IsCrafting && timer.Elapsed.Seconds < 3) { if (controlKey) { Utilities.Keyboard.KeyBoardHelper.Ctrl(key); } else { Utilities.Keyboard.KeyBoardHelper.KeyPress(key); } user.Refresh(); } Debug.Print("Waiting for start: " + timer.Elapsed.Milliseconds.ToString()); //while ((user.Status == CharacterStatus.Idle || user.Status == CharacterStatus.Crafting_Idle) && user.IsCrafting && timer.Elapsed.Seconds < 4) //{ // user.Refresh(); //} // Debug.Print("After: " + user.Status.ToString() + " " + user.IsCrafting.ToString()); timer.Restart(); while ((user.UsingAbility == true) && user.IsCrafting && timer.Elapsed.Seconds < 3) { user.Refresh(); } Debug.Print("Ability Finished: " + timer.Elapsed.Milliseconds.ToString()); //while (user.Status != CharacterStatus.Idle && user.Status != CharacterStatus.Crafting_Idle2 && user.IsCrafting && timer.Elapsed.Seconds < 7) //{ // user.Refresh(); //} //Debug.Print("After2: " + user.Status.ToString() + " " + user.IsCrafting.ToString()); user.Refresh(); //Debug.Print("End: " + user.Status.ToString() + " " + user.IsCrafting.ToString()); Thread.Sleep(300); }