private void checkProcess(object state) { notFound(); if (String.IsNullOrWhiteSpace(ProcessName)) { return; } String actualProcessName = Path.GetFileNameWithoutExtension(ProcessName); log.Trace($"Try to find process: {actualProcessName}."); Process[] processes = Process.GetProcessesByName(actualProcessName); IsRunning = processes?.Length > 0; IntPtr?winHandle = processes?.FirstOrDefault()?.MainWindowHandle; if (winHandle.HasValue) { RECT winBounds; GetWindowRect(new HandleRef(this, winHandle.Value), out winBounds); WinLoc = new Point(winBounds.Left, winBounds.Top); WinSize = new Size(winBounds.Right - winBounds.Left, winBounds.Bottom - winBounds.Top); IntPtr activeWindow = GetForegroundWindow(); IsActive = activeWindow == winHandle.Value; } }
private Point getHookPos() { //Point F_initialMousePos = MouseInteropHelper.getCursorPos(); Input.Mouse.User32_MousePosition mousePos = new Input.Mouse.User32_MousePosition(); double screenWidth = ScreenHelper.getActualPrimaryScreenWidth(); double screenHeight = ScreenHelper.getActualPrimaryScreenHeight(); Point rectLocation = mousePos.GetCursorPos(); //get MousePos --> center of new rect log.Debug($"Start searching for hook at {rectLocation.ToString()}."); rectLocation.Offset(-screenWidth / 4, -screenWidth / 4); //move point to use it as rect location Rect halfScreenWidthSquare = new Rect(rectLocation, new Size(screenWidth / 2, screenWidth / 2)); log.Debug($"Search for hook in area: {halfScreenWidthSquare.ToString()}"); IEnumerator <Point> coords = new CoordinateProvider.RectSpiral(halfScreenWidthSquare); while (coords.MoveNext() && timerEnabled) { // 1 Move Cursor Point p = coords.Current; log.Trace($"Set mouse pos at {p.ToString()}."); mousePos.SetCursorPos(p); Thread.Sleep(10); // 2 Compare Cursor if (Equals(Input.Mouse.Cursor.GetCursorImg(), SpongeBot.Properties.Resources.HookCursor)) { log.Info($"Found bobber at {p.ToString()}). Wait and recheck."); //p = new Point(p.X + 30, p.Y + 30); // works well @ 1080p & first person view & line by line //mousePos.SetCursorPos(p); Thread.Sleep(250); //cursor might change due to bobber movement when mouse is at the very corner if (Equals(Input.Mouse.Cursor.GetCursorImg(), SpongeBot.Properties.Resources.HookCursor)) { log.Notice($"Found bobber at {p.ToString()})."); return(p); } } } throw new Exception("No Bobber found in area."); }
/* * * Configuration config = WebConfigurationManager.OpenWebConfiguration("/"); * string oldValue = config.AppSettings.Settings["SomeKey"].Value; * config.AppSettings.Settings["SomeKey"].Value = "NewValue"; * config.Save(ConfigurationSaveMode.Modified); */ // GET: Manage/Settings public ActionResult Index() { log.Trace("ApplicationSettings Index view opened"); return(View(ConfigurationManager.AppSettings)); }
public void GetClientByCode() { log.Trace("your verbose message here"); //.... }
private void Window_SizeChanged(object sender, SizeChangedEventArgs e) { log.Trace($"Size changed from {e.PreviousSize} to {e.NewSize}."); fitImg(); }