public OverlayForm(HomeForm parent) { //get home screen object HOMEFORM = parent; //set current form as object OVERLAYFORM = this; InitializeComponent(); HomeConfig temp = HOMEFORM.CONFIG_FILE.homeButtonConfig; //set home button image HomeButton.Image = Image.FromFile(Path.Combine(HOMEFORM.CONFIG_FILE.resourceFolder, temp.backgroundImageName)); HomeButton.Click += HomeButton_Click; HomeButton.Paint += ButtonText_Paint; //set button size OVERLAYFORM.Size = new Size(temp.buttonWidth, temp.buttonHeight); HomeButton.Size = new Size(temp.buttonWidth, temp.buttonHeight); //move home button to position Rectangle workingArea = Screen.GetWorkingArea(OVERLAYFORM); if (temp.buttonPosition == "TOPRIGHT") { OVERLAYFORM.Location = new Point(workingArea.Right - temp.buttonWidth - temp.buttonPaddingHorizontal, workingArea.Top + temp.buttonPaddingVertical); } else if (temp.buttonPosition == "TOPLEFT") { OVERLAYFORM.Location = new Point(workingArea.Left + temp.buttonPaddingHorizontal, workingArea.Top + temp.buttonPaddingVertical); } else if (temp.buttonPosition == "BOTTOMRIGHT") { OVERLAYFORM.Location = new Point(workingArea.Right - temp.buttonWidth - temp.buttonPaddingHorizontal, workingArea.Bottom - temp.buttonHeight - temp.buttonPaddingVertical); } else if (temp.buttonPosition == "BOTTOMLEFT") { OVERLAYFORM.Location = new Point(workingArea.Left + temp.buttonPaddingHorizontal, workingArea.Bottom - temp.buttonHeight - temp.buttonPaddingVertical); } //timeout config TIMEOUT = HOMEFORM.CONFIG_FILE.timeoutTime; MAXIDLE = HOMEFORM.CONFIG_FILE.idleTimeout / IDLEINTERVAL; //set idle check hooks _proc = HookCallback; kh.KeyDown += Kh_KeyDown; _hookID = SetHook(_proc); }