static void Main() { // Make sure this is the only "Smart Clicker" running! bool ok; Mutex m = new System.Threading.Mutex(true, "Smart Clicker", out ok); if (!ok) { return; } // Set handler for all uncaught exceptions, so we can restart Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); // Set Global application parameters System.Diagnostics.Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Initialize the application ClickStatus status = new ClickStatus(); CustomizationParameters customParams = new XmlMethods().loadFromXML(); MainForm mainForm = new MainForm(status, customParams); ClickDetector clickDetector = new ClickDetector(status, new CursorCapture(), customParams, mainForm); mainForm.detector = clickDetector; Application.ThreadException += new ThreadExceptionEventHandler(mainForm.CatchFatalException); Application.Run(mainForm); GC.KeepAlive(m); }
static void Main() { bool ok; Mutex m = new System.Threading.Mutex(true, "Smart Clicker", out ok); if (!ok) { return; } Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); System.Diagnostics.Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ClickStatus status = new ClickStatus(); CustomizationParameters customParams = new XmlMethods().loadFromXML(); MainForm mainForm = new MainForm(status, customParams); ClickDetector clickDetector = new ClickDetector(status, new CursorCapture(), customParams, mainForm); mainForm.detector = clickDetector; Application.ThreadException += new ThreadExceptionEventHandler(mainForm.CatchFatalException); Application.Run(mainForm); GC.KeepAlive(m); }
public ClickDetector(ClickStatus status, CursorCapture capture, CustomizationParameters parameters, MainForm form) { this.status = status; this.capture = capture; this.parameters = parameters; this.form = form; this.lastClick = new cursorInTime(-50, -50, null); InitTimer(); this.automator = new CUIAutomation(); }
public ClickDetector(ClickStatus status, CursorCapture capture, CustomizationParameters parameters, MainForm form) { this.status = status; this.capture = capture; this.parameters = parameters; this.form = form; this.lastClick = new cursorInTime(-50, -50, null); InitTimer(); this.automator = new CUIAutomation(); this.lastSentToBack = 0; }
public MainForm(ClickStatus status, CustomizationParameters customParams) { fetcher = new Fetcher(this); fetcher.Show(); InitializeComponent(); this.ShowInTaskbar = false; this.clickStatus = status; this.customParams = customParams; ContextMenu trayMenu = new ContextMenu(); trayMenu.MenuItems.Add("Exit", OnExit); this.trayIcon = new NotifyIcon(); trayIcon.Text = "SmartClicker"; trayIcon.Icon = this.Icon; // Add menu to tray icon and show it. trayIcon.ContextMenu = trayMenu; trayIcon.Visible = true; //buttons1 = new PictureBox[] { sleepClick, contextClick, leftClick, rightClick, doubleClick, clickAndDrag, CustomForm, help }; this.buttons = new PictureBox[] {sleepClick, contextClick, leftClick, rightClick , doubleClick, clickAndDrag, help}; foreach (PictureBox mode in buttons) { if (!(mode.Name == "help")) { mode.MouseHover += new EventHandler(pictureBox_MouseHover); } } // need to add a mouse hover handler to the config and help button too CustomForm.MouseHover += new EventHandler(CustomForm_MouseHover); //CustomForm.MouseHover += new EventHandler(pictureBox_MouseHover); help.MouseHover += new EventHandler(help_MouseHover); ModeMapping = new Dictionary<PictureBox, ProgramMode>() { {leftClick, ProgramMode.leftClick}, {rightClick, ProgramMode.rightClick}, {doubleClick, ProgramMode.doubleClick}, {contextClick, ProgramMode.contextClick}, {clickAndDrag, ProgramMode.clickAndDrag}, {sleepClick, ProgramMode.sleepClick} }; inverseModeMapping = new Dictionary<ProgramMode, PictureBox>(); foreach(PictureBox box in ModeMapping.Keys) { inverseModeMapping.Add(ModeMapping[box], box); } // need to read from xml and redraw based on prefs this.redraw(); this.MaximizeBox = false; this.MinimizeBox = false; this.Text = String.Empty; this.StartPosition = FormStartPosition.Manual; this.Left = this.customParams.layoutValues.startLeft; this.Top = this.customParams.layoutValues.startTop; this.Width = this.customParams.layoutValues.startWidth; this.Height = this.customParams.layoutValues.startHeight; this.FormClosing += new FormClosingEventHandler(MainForm_FormClosing); setPictureBoxLock(contextClick); }
public MainForm(ClickStatus status, CustomizationParameters customParams) { // Initialize Fetcher icon, that pulls main form forward when moused over, and is always TopForm this.fetcher = new Fetcher(this, customParams); fetcher.Show(); // Set starting variables InitializeComponent(); this.clickStatus = status; this.customParams = customParams; // Set Windows Application parameters and add tray icon this.ShowInTaskbar = false; ContextMenu trayMenu = new ContextMenu(); trayMenu.MenuItems.Add("Exit", OnExit); this.trayIcon = new NotifyIcon(); trayIcon.Text = "SmartClicker"; trayIcon.Icon = this.Icon; // Add menu to tray icon and show it. trayIcon.ContextMenu = trayMenu; trayIcon.Visible = true; // This holds every hide-able picturebox for different program modes this.buttons = new PictureBox[] { sleepClick, contextClick, leftClick, rightClick, doubleClick, clickAndDrag }; foreach (PictureBox mode in buttons) { mode.MouseHover += new EventHandler(pictureBox_MouseHover); } // Need to add a mouse hover handler to the config button too CustomForm.MouseHover += new EventHandler(CustomForm_MouseHover); // Create a mapping from picture boxes to default program modes, so we can set them if they are selected ModeMapping = new Dictionary <PictureBox, ProgramMode>() { { leftClick, ProgramMode.leftClick }, { rightClick, ProgramMode.rightClick }, { doubleClick, ProgramMode.doubleClick }, { contextClick, ProgramMode.contextClick }, { clickAndDrag, ProgramMode.clickAndDrag }, { sleepClick, ProgramMode.sleepClick } }; // Create an inverse mapping so the detector can also change how pictureboxes look inverseModeMapping = new Dictionary <ProgramMode, PictureBox>(); foreach (PictureBox box in ModeMapping.Keys) { inverseModeMapping.Add(ModeMapping[box], box); } // Redraw the MainForm to match XML configuration this.redraw(); // Initialize the form to the XML/default parameters this.MaximizeBox = false; this.MinimizeBox = false; this.Text = String.Empty; this.StartPosition = FormStartPosition.Manual; this.Left = Math.Min(this.customParams.layoutValues.startLeft, Screen.PrimaryScreen.Bounds.Width - this.customParams.layoutValues.startWidth); this.Top = Math.Max(this.customParams.layoutValues.startTop, this.customParams.clickValues.clickBoundingBox); this.Width = this.customParams.layoutValues.startWidth; this.Height = this.customParams.layoutValues.startHeight; // Add handler to ask "Are you sure?" dialog this.FormClosing += new FormClosingEventHandler(MainForm_FormClosing); setPictureBoxLock(contextClick); }