How to implement Ctrl+click & Ctrl+Shift+click event in a C# project/scrip?

A-Bot:
Is it possible to create list of actions for executing in one step?
For example i need Ctrl+MouseClick for locking target.

My realisation:
using Sanderling.Interface.MemoryStruct;
using Sanderling.Motor;
using System.Collections.Generic;
using WindowsInput.Native;

namespace Sanderling.ABot.Bot.Task
{
	class LockTargetTask :IBotTask
	{
		private IOverviewEntry target;

		public LockTargetTask(IOverviewEntry target)
		{
			if (target != null)
				this.target = target;
		}

		public IEnumerable<IBotTask> Component => null;

		public IEnumerable<MotionParam> Effects
		{
			get
			{
				if (target == null)
					yield break;

				var ctrlKey = VirtualKeyCode.CONTROL;

				yield return ctrlKey.KeyDown();
				yield return target.MouseClick(BotEngine.Motor.MouseButtonIdEnum.Left);			
				yield return ctrlKey.KeyUp();

			}
		}
	}
}

I have 3 steps: Ctrl key down, mouse click, Ctrl key up. Each iteration checks several conditions.
Soo, sometimes my bot have bug:

  • check conditions
  • Ctrl key down
  • check conditions
  • mouse click
  • check conditions
    But the conditions had changed and “Ctrl key up” action never executed.
1 Like