1

I have an application for kiosk machine that appears always on the top and fullscreen. Also, I have to turn off explorer.exe.

Therefore, I will not be able to access anything without a keyboard.

I'm thinking to make gestures or invincible buttons so that I can turn on explorer.exe without keyboard.

I would like to know if there is a way to detect if two buttons are clicked at the same time. I've tried using the following code but it is not working.

PS: I can't debug it line by line as my PC do not have touchscreen. Therefore, I cannot find out which line causes the problem.

    private bool button1WasClicked = false;
    private bool button2WasClicked = false;

    private void button1_MouseDown(object sender, MouseEventArgs e)
    {
        button1WasClicked = true;
    }

    private void button1_MouseUp(object sender, MouseEventArgs e)
    {
        button1WasClicked = false;
    }

    private void button2_MouseUp(object sender, MouseEventArgs e)
    {
        button2WasClicked = false;
    }

    private void button2_MouseDown(object sender, MouseEventArgs e)
    {
        if (button1WasClicked == true)
        {
            Process.Start(Path.Combine(Environment.GetEnvironmentVariable("windir"), "explorer.exe"));
            Application.Exit();
            button1WasClicked = false;
        }
    }
active92
  • 644
  • 12
  • 24
  • 1. what do you mean by turn on/off explorer.exe? 2. maybe better try [key Modifiers](http://stackoverflow.com/questions/1434867/how-to-use-multiple-modifier-keys-in-c-sharp) – Lei Yang Dec 05 '16 at 02:51
  • @LeiYang if `explorer.exe` is turned off, the taskbar will be gone as well. I will have to turn it back on during maintenance. I will require keyboard to use `key modifiers`. As I have mentioned in my question, I will have to do this without keyboard. – active92 Dec 05 '16 at 02:54
  • How can a button be clicked if it is invisible? – Kinetic Dec 05 '16 at 02:54
  • 1
    And how can two buttons be clicked at the same time? – Kinetic Dec 05 '16 at 02:55
  • @Kinetic I still set the `visible` properties to `true` but set FlatStyle to flat. Set BorderColor, MouseDownBackColor and MouseOverBackColor to BackColor so that user can't see it. If it is touchscreen, two buttons can be touch at the same time. – active92 Dec 05 '16 at 02:59
  • Could you expand your situation/problem? Questions asked by @Kinetic seem to be sensible. – Facundo La Rocca Dec 05 '16 at 03:00
  • How can a pc not have keyboard? If you don't have a keyboard, how do you login windows? – Lei Yang Dec 05 '16 at 03:03
  • @FacundoLaRocca I'm trying to create a backdoor to turn on `explorer.exe` on a touchscreen pc without keyboard. My idea is to let the maintenance team touch two buttons on the application to close the application and turn on `explorer.exe`. – active92 Dec 05 '16 at 03:03
  • I could be wrong about this, but I'm pretty sure that even with a touch screen you can't click two buttons at the same time using winform. Well you can, but one of the click will be processed before the other one. – Kinetic Dec 05 '16 at 03:03
  • @LeiYang the application is a kiosk machine where keyboard will not be plugged as there are limited usb ports. The PC is set to turn on once the power is on. There is no password required to login. The application will automatically turn on once pc starts. – active92 Dec 05 '16 at 03:05
  • @Kinetic got it. will try to find alternative. thanks. – active92 Dec 05 '16 at 03:12

2 Answers2

0

You can't click two buttons at once with a mouse or keyboard, and if you're talking about using a touchscreen, the WinForms framework doesn't support them (taps will simply be interpreted as individual mouse clicks at best). You'll want to look at using the Surface SDK or something else instead.

Extragorey
  • 1,654
  • 16
  • 30
0

I've found a different solution where the buttons(panels) have to be clicked in a certain sequence to achieve what I wanted. I've also added a timer. Below is my code.

    private bool panel1WasClicked = false;
    private bool panel2WasClicked = false;
    int second = 0;
    private void panel1_Click(object sender, EventArgs e)
    {
        MaintenanceTimer.Interval = 500;
        MaintenanceTimer.Start();
        second = 0;

        if (panel1WasClicked == false)
        {
            panel1WasClicked = true;
        }

        else
        {
            panel1WasClicked = false;
        }

    }

    private void panel2_Click(object sender, EventArgs e)
    {
        if (panel2WasClicked == false && panel1WasClicked == true)
        {
            panel2WasClicked = true;
        }

        else
        {
            panel2WasClicked = false;
        }

    }

    private void panel3_Click(object sender, EventArgs e)
    {
        if (panel1WasClicked && panel2WasClicked == true)
        {
            //Do something
        }

        panel1WasClicked = false;
        panel2WasClicked = false;
        MaintenanceTimer.Stop();
    }

    private void MaintenanceTimer_Tick(object sender, EventArgs e)
    {
        second += 1;
        if (second >= 5)
        {
            MaintenanceTimer.Stop();
            second = 0;
            panel1WasClicked = false;
            panel2WasClicked = false;

        }
    }
active92
  • 644
  • 12
  • 24