private void Initialize() { const string KEY_CROP_FILENAME = "key.lvb"; const int KEY_CROP_X = 250, KEY_CROP_Y = 473, KEY_CROP_WIDTH = 524, KEY_CROP_HEIGHT = 58; const string BAR_CROP_FILENAME = "bar.lvb"; const int BAR_CROP_X = 254, BAR_CROP_Y = 518, BAR_CROP_WIDTH = 524, BAR_CROP_HEIGHT = 43; windowFinder = new WindowFinder(); imageFinder = new ImageFinder(0.9); // load all images based on Signal types. throws error if any of these are not found foreach (Signal s in Enum.GetValues(typeof(Signal))) { string subImagePath = String.Format("{0}{1}{2}", IMAGE_PATH, s.ToString(), IMAGE_EXT); imageFinder.SubImages.Add(s, new Image<Bgr, byte>(subImagePath)); } // init gamestate for (int i = 0; i < gameState.Length; i++) { gameState[i] = new Signal[KEY_COLUMNS_MAX]; } keyCropSettings = CropSettings.Load(KEY_CROP_FILENAME, KEY_CROP_X, KEY_CROP_Y, KEY_CROP_WIDTH, KEY_CROP_HEIGHT); keyCropSettings.SaveIfNotExist(KEY_CROP_FILENAME); barCropSettings = CropSettings.Load(BAR_CROP_FILENAME, BAR_CROP_X, BAR_CROP_Y, BAR_CROP_WIDTH, BAR_CROP_HEIGHT); barCropSettings.SaveIfNotExist(BAR_CROP_FILENAME); }
/* end http://stackoverflow.com/a/1524047 */ public Overlay(BotLogic _owner, int _keyOffsetX, int _keyOffsetY, string process) { InitializeComponent(); owner = _owner; keyOffsetX = _keyOffsetX; keyOffsetY = _keyOffsetY - 50; overlayFont = new Font(FontFamily.GenericMonospace, 10f); creditBrush = new SolidBrush(Color.Aqua); initializeOverlayBrushes(); backgroundBrush = new SolidBrush(Color.Black); windowFinder = new WindowFinder(); windowFinder.SetProcess(process); // todo: add hooks programatically keyboardHook = new globalKeyboardHook(); keyboardHook.KeyDown += KeyboardHook_KeyDown; keyboardHook.HookedKeys.Add(toggleKey); keyboardHook.HookedKeys.Add(toggleVisibleKey); keyboardHook.HookedKeys.Add(toggleKeyModeKey); keyboardHook.HookedKeys.Add(toggleAutoReadyKey); keyboardHook.HookedKeys.Add(dumpKey); keyboardHook.hook(); Byte[] bitmapData = Convert.FromBase64String(CREDIT_IMAGE_B64); using (System.IO.MemoryStream streamBitmap = new System.IO.MemoryStream(bitmapData)) { creditImage = (Bitmap)Image.FromStream(streamBitmap); } creditImageEnabled = getColoredBitmap(creditImage, Color.FromArgb(0, 1, 0)); creditImageDisabled = getColoredBitmap(creditImage, Color.FromArgb(1, 0, 0)); this.DoubleBuffered = true; //owner.Start(); }