Esempio n. 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.Text += " - Ver ";
            this.Text += new FileInfo(Application.ExecutablePath).LastWriteTime.ToString("yyMMdd");
            if (!Authenticate())
            {
                MessageBox.Show("Error!");
                Close();
            }

            try
            {
                cbbCaNhan.SelectedIndex = Properties.Settings.Default.CaNhan;
                cbbDoi.SelectedIndex    = Properties.Settings.Default.Doi;
                cbbHuy.SelectedIndex    = Properties.Settings.Default.Huy;
                cbbCall.SelectedIndex   = Properties.Settings.Default.Call;
                cbbScan.SelectedIndex   = Properties.Settings.Default.Scan;


                kHook          = new LowLevelHooks.Keyboard.KeyboardHook();
                kHook.KeyDown += KHook_KeyDown;
                kHook.Hook();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
 public Form1()
 {
     InitializeComponent();
     kHook = new KeyboardHook();
     mHook = new MouseHook();
     kHook.KeyEvent += KHookKeyEvent;
     mHook.MouseEvent += MHookMouseEvent;
     FormClosing += Form1FormClosing;
 }
Esempio n. 3
0
        public Form1()
        {
            InitializeComponent();
            kHook = new KeyboardHook();
            kHook.KeyEvent += KHookKeyEvent;
            FormClosing += Form1FormClosing;
            kHook.Hook(); // dispose() unhooks

            // Keycode lists:
            //TODO: add error handling
            XmlDocument inputmap = new XmlDocument();
            inputmap.Load("../../../configuration/LEDBlinkyInputMap.xml");

            XmlNodeList keycodeList;
            keycodeList = inputmap.SelectNodes(".//port[@type='R']"); // Grabbing the red ports to get a count
            KeyCodes = new String[keycodeList.Count];

            int j = 1;
            for (int i = 0; i < keycodeList.Count; i++)
            {
                XmlElement keycode = (XmlElement)inputmap.SelectSingleNode(".//port[@number='" + j + "']");
                j = j + 3;

                //String is a bit wrong, fix it here to avoid another loop
                String kc_string = keycode.GetAttribute("inputCodes").Substring(8); // trim "KEYCODE_"
                // check if length is 1, if so, add "K_" to the start, else add "VK_" to match virtual keycodes enum.
                if (kc_string.Length == 1)
                {
                    kc_string = "K_" + kc_string;
                }
                else
                {
                    kc_string = "VK_" + kc_string;
                }

                // fix alt keys (called VK_LMENU and VK_RMENU in windows virtual keycodes)
                if (kc_string == "VK_LALT" || kc_string == "VK_RALT")
                {
                    kc_string = kc_string.Substring(0, 4) + "MENU";
                }
                // fix escape key
                if (kc_string == "VK_ESC")
                {
                    kc_string = "VK_ESCAPE";
                }
                // expect more fixes here

                // assign
                KeyCodes[i] = kc_string;
            }
        }