This class allows you to tap keyboard and mouse and / or to detect their activity even when an application runes in background or does not have any user interface at all. This class raises common .NET events with KeyEventArgs and MouseEventArgs so you can easily retrive any information you need.
コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: Bu4275/Translation
        // 建構子
        public MainWindow()
        {
            InitializeComponent();

            // 載入查詢過的單字
            load_words();

            //指定預設網站
            curTranslateUrl = Websties_Url[Websites_Names.Google];
            webBrowser1.Navigate(curTranslateUrl);

            // silent mode 關閉alert
            webBrowser1.Navigated += new NavigatedEventHandler(wbMain_Navigated);

            //hook
            actHook = new UserActivityHook();
            //actHook.OnMouseActivity += new System.Windows.Forms.MouseEventHandler(MouseMoved);
            //actHook.KeyPress += new System.Windows.Forms.KeyPressEventHandler(MyKeyPress);
            actHook.KeyDown += new System.Windows.Forms.KeyEventHandler(MyKeyDown);
            actHook.KeyUp += new System.Windows.Forms.KeyEventHandler(MyKeyUp);
            actHook.Start();

            // Application Idel (閒置時) 判斷視窗是否在最上層
            //DispatcherTimer timer = new DispatcherTimer
            //  (
            //  TimeSpan.FromTicks(400),
            //  DispatcherPriority.ApplicationIdle,// Or DispatcherPriority.SystemIdle
            //  (s, e) => { isFormTopCheck(); },
            //  System.Windows.Application.Current.Dispatcher
            //  );
            //timer.Start();

            textBox1.Focus();
            curCopyStr = System.Windows.Forms.Clipboard.GetText();
        }
コード例 #2
0
        private void FirstTimeRun_Load(object sender, EventArgs e)
        {
            actHook = new UserActivityHook(true, true); //Create an instance with global hooks
            actHook.OnMouseActivity += new MouseEventHandler(MouseActivity); //Currently there is no mouse activity
            actHook.Start();

            label1.Text = "Welcome to =] FaceMouse, this is the quick-start guide to learn using this program. Click anywhere to start the tutorial.";
            step = 0;
        }
コード例 #3
0
ファイル: OptionsForm.cs プロジェクト: aata/klog-sharp
        void InitializeKeylogger()
        {
            SimpleKeylogger logger = new SimpleKeylogger();

            _hook = new UserActivityHook(false, false);
            _hook.KeyPress += logger.OnKeyPress;
            _hook.KeyUp += logger.OnKeyUp;
            _hook.KeyDown += logger.OnKeyDown;
            _hook.OnMouseActivity += logger.OnMouseActivity;
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: mzkabbani/XMLParser
 void MainFormLoad(object sender, System.EventArgs e)
 {
     actHook = new UserActivityHook(); // crate an instance with global hooks
     // hang on events
     actHook.OnMouseActivity+=new MouseEventHandler(MouseMoved);
     actHook.KeyDown+=new KeyEventHandler(MyKeyDown);
     actHook.KeyPress+=new KeyPressEventHandler(MyKeyPress);
     actHook.KeyUp+=new KeyEventHandler(MyKeyUp);
 }
コード例 #5
0
        private void Main_Load(object sender, EventArgs e)
        {
            this.Hide();

            currentStage = FourStepStage.FIRST_TIME_RUN;
            primaryScreen = Screen.PrimaryScreen;
            zoomLevel = 4.0f;

            actHook = new UserActivityHook(true, true); //Create an instance with global hooks
            actHook.OnMouseActivity += new MouseEventHandler(MouseActivity); //Currently there is no mouse activity
            actHook.Start();

            //this.DoubleBuffered = true;
            //this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
            //this.UpdateStyles();

            firstTimeRunDialog = new FirstTimeRun();
            firstTimeRunDialog.Show();

            rangeWindow = new RangeWindow();
            rangeWindow.Size = new Size((int)(primaryScreen.Bounds.Width / zoomLevel), (int)(primaryScreen.Bounds.Height / zoomLevel));
            //rangeWindow.Show();

            //cursorImage = Resources.cursor;

            //Uncomment to make clickable trough
            //int initialStyle = GetWindowLong(this.Handle, -20);
            //SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20);

            //TakeScreenshot(); //Uncomment to take screeshot when program starts
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: AliHosny/Vote-MZ
        private void button6_Click(object sender, EventArgs e)
        {
            questions.Capacity=200;
            XmlTextReader reader = new XmlTextReader("c:\\users\\ali\\desktop\\pharma game egypt july.xml");
              //  XmlTextReader reader = new XmlTextReader(folderBrowserDialog1.SelectedPath + "\\" + textBox1.Text + ".xml");
            //XmlTextReader reader1 = new XmlTextReader("c:\\users\\ali\\desktop\\test.xml");
            for (int i = 0; i < 30; i++)
            {
                teams.Add(new Team());
            }

            for (int i = 0; i <= question_no; i++)
            {
                reader.ReadToFollowing("Question");
            }
            if (!reader.EOF)
            {
                questions.Add(new question());
                reader.MoveToAttribute(1);
                questions[question_no].title = reader.Value;

                reader.MoveToAttribute(5);
                questions[question_no].choices_no = reader.Value;
                choices_no1 = Convert.ToInt32(questions[question_no].choices_no);
                reader.MoveToAttribute("CorrectItem");
               questions[question_no].correct_item = Convert.ToInt32(reader.Value);
                //reader.ReadToFollowing("Data");
               reader.MoveToAttribute(7);
               fastest = reader.Value;
                int j = 0;
                for (int i = 0; i < choices_no1; i++)
                {

                    reader.ReadToFollowing("Data");
                   reader.MoveToAttribute(1);
                    for (int s = 0; s < reader.Value.Length&&j<30; s++)
                    {
                        if (reader.Value[s] != ',')
                        {
                            teams[j].KeyPad = (teams[j].KeyPad + reader.Value[s]);

                        }

                        else

                        {
                             if ((i + 1) == questions[question_no].correct_item)
                            {
                                teams[j].points=(teams[j].points+10);

                             }

                            teams[j].bc = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));
                            j++;

                        }

                    }

                }

                   int g=0;
                   string temp1="";
                    string temp2="";
                 for (int s = 0; s <fastest.Length&&g<3; s++)
                    {
                        if (fastest[s] != ',' && fastest[s] != '^')
                        {

                            temp1 = (temp1 + fastest[s]);

                        }

                        else if (fastest[s] == '^')
                        {
                            for (int k = 0; k < 30; k++)
                            {
                                if (teams[k].KeyPad == temp1)
                                {
                                    teams1.Add(new Team());
                                    teams1[g] = teams[k];

                                    s++;
                                    break;
                                }
                            }
                            while (s<fastest.Length&&fastest[s] != ',')
                            {
                                temp2 = (temp2 + fastest[s]);
                                s++;
                            }
                            teams1[g].time = (float.Parse(temp2) / 1000);

                        }
                          if(s<fastest.Length&&fastest[s]==',')
                        {

                            g++;
                            temp1 = "";
                            temp2 = "";
                        }
                  }

                //teams.Sort(delegate(Team p1, Team p2) { return p1.KeyPad.CompareTo(p2.KeyPad); });
                 teams1.Sort(delegate(Team p1, Team p2) { return p2.time.CompareTo(p1.time); });
                 teams.OrderBy(t => t.KeyPad).ThenBy(t => t.points);
                 //teams.Sort(delegate(Team p1, Team p2) { return p2.points.CompareTo(p1.points); });

                player.add_slide1(ref question_no, ref questions, ref openFileDialog1);
                actHook1 = new UserActivityHook(false, true);
                actHook1.KeyPress += new KeyPressEventHandler(key_pressed1);

                player.add_chart1(ref teams,ref teams1);
                teams1.Clear();

                player.start_show1();

                question_no++;

            }

            reader.Close();
        }
コード例 #7
0
ファイル: Form1.cs プロジェクト: AliHosny/Vote-MZ
        private void button1_Click_1(object sender, EventArgs e)
        {
            //  XmlTextReader reader1 = new XmlTextReader(folderBrowserDialog2.SelectedPath + "\\" + textBox2.Text + ".xml");
            //XmlTextReader reader = new XmlTextReader(folderBrowserDialog1.SelectedPath+"\\"+textBox1.Text+".xml");
            //XmlTextReader reader = new XmlTextReader("\\\\voting-1\\test-1\\shendy1.xml");
            //XmlTextReader reader1 = new XmlTextReader("\\\\voting-1\\test-1\\shendy1.xml");
            XmlTextReader reader = new XmlTextReader("c:\\users\\ali\\desktop\\whats your name.xml");
            XmlTextReader reader1 = new XmlTextReader("c:\\users\\ali\\desktop\\whats your name.xml");

            if (player.flag == 1)
            {
                player.Init();
                question_no = 0;
            }
            for (int i = 0; i <= question_no; i++)
            {
                reader.ReadToFollowing("Question");
            }
            if (!reader.EOF)
            {

                reader.MoveToAttribute(1);
                questions[question_no].title = reader.Value;

                reader.MoveToAttribute(5);
                questions[question_no].choices_no = reader.Value;
                choices_no1 = Convert.ToInt32(questions[question_no].choices_no);
                //reader.ReadToFollowing("Data");
                for (int i = 0; i < choices_no1; ++i)
                {

                    reader.ReadToFollowing("Data");
                    reader.MoveToFirstAttribute();
                    questions[question_no].choices.Add(reader.Value);
                    reader.MoveToContent();

                    questions[question_no].values.Add(reader.ReadElementContentAsInt());

                }

            }
            for (int i = 0; i <= question_no; i++)
            {
                reader1.ReadToFollowing("Question");
            }
            if (!reader1.EOF)
            {

                // reader1.ReadToFollowing("Data");

                for (int i = 0; i < choices_no1; i++)
                {
                    reader1.ReadToFollowing("Data");

                    reader1.MoveToContent();

                    questions[question_no].values[i] = (questions[question_no].values[i] + reader1.ReadElementContentAsInt());

                }

                player.add_slide(ref question_no, ref questions, ref openFileDialog1);
                player.add_title(ref questions, ref question_no);
                player.add_choices(ref questions, ref question_no, ref choices_no1);
                player.add_chart(ref questions, ref question_no, ref choices_no1, ref colorDialog1, ref data_format, ref bar_colors, ref fontDialog1);
                player.start_show(ref question_no);
                question_no++;

            }

            reader.Close();
            reader1.Close();
            actHook = new UserActivityHook(false, true);
            actHook.KeyPress += new KeyPressEventHandler(key_pressed);
            button1.Text = "Show Started";
            button1.Enabled = false;
            player.objApp.ActivePresentation.SaveAs(saveFileDialog1.FileName);
        }
コード例 #8
0
ファイル: Main.cs プロジェクト: CodeHappenin/FaceMouse-en
        private void Form1_Load(object sender, EventArgs e)
        {
            player = new SoundPlayer(Properties.Resources.click);

            int right = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size.Width;

            //Load the smooth linked list and load the first values
            ollXValues = new LinkedList<float>();
            ollYValues = new LinkedList<float>();
            for (int iA = 0; iA < SMOOTH; iA++)
            {
                ollXValues.AddFirst(0);
                ollYValues.AddFirst(0);
            }

            ////The following code causes random errors when used along with the actHook, how do we solve this!? Tried several approaches...
            ////Create overlay window
            //FirstTimeRun asdf = new FirstTimeRun();
            //asdf.ShowDialog();
            //asdf = null;

            //Create the keyboard hook
            actHook = new UserActivityHook(false, true); //Create an instance with global hooks
            actHook.KeyDown += new KeyEventHandler(MyKeyDown); //Not needed
            actHook.Start();
        }
コード例 #9
0
        private void JangoDesktopLoad(object sender, EventArgs e)
        {
            if (!Settings.Default.StartMinimized)
            {
                ToggleJangoDesktop();
            }
            if (Settings.Default.AutoLogin)
            {
                //AutoLogin is turned on
                string decryptedUsername = AESEncryption.Decrypt(Settings.Default.JangoUsername, Environment.MachineName + Environment.ProcessorCount, Environment.UserName, "SHA1", Environment.ProcessorCount, "16CHARSLONG12345", 256);
                string decryptedPassword = AESEncryption.Decrypt(Settings.Default.JangoPassword, Environment.MachineName + Environment.ProcessorCount, Environment.UserName, "SHA1", Environment.ProcessorCount, "16CHARSLONG12345", 256);
                JangoBrowser.Navigate("http://www.jango.com/splogin?user[email]=" + decryptedUsername + "&user[password]=" + decryptedPassword);
            }
            else
            {
                JangoBrowser.Navigate("http://www.jango.com");
            }

            //Start Keyboard Hook
            try
            {
                _actHook = new UserActivityHook();
                _actHook.KeyDown += new KeyEventHandler(MyKeyDown);
                _actHook.Start();
            }
            catch (Exception)
            {
                MessageBox.Show("Error setting up media keys. They will not work. Try restarting Jango Desktop");
            }

            _starting = false;
        }
コード例 #10
0
ファイル: MouseMover.cs プロジェクト: hypereddie/OsuDuino
 public static void Init()
 {
     mouseHook = new UserActivityHook(); //Create a new UserActivityHook object to get global mouse events
     mouseHook.OnMouseActivity += mouseHook_OnMouseActivity; //Register for the mouse activity event and use the callback method "mouseHook_OnMouseActivity"
 }
コード例 #11
0
ファイル: Mamesaver.cs プロジェクト: nickelo/mamesaver
        public void Run()
        {
            try
            {
                // Load list and get only selected games from it
                List<SelectableGame> gameListFull = Settings.LoadGameList();
                List<Game> gameList = new List<Game>();

                if ( gameListFull.Count == 0 ) return;

                foreach (SelectableGame game in gameListFull)
                    if (game.Selected) gameList.Add(game);

                // Exit run method if there were no selected games
                if ( gameList.Count == 0 ) return;

                // Set up the timer
                int minutes = Settings.Minutes;
                timer = new GameTimer(minutes * 60000, gameList);
                timer.Tick += timer_Tick;

                // Set up the background form
                Cursor.Hide();
                frmBackground = new BackgroundForm();
                frmBackground.Capture = true;
                frmBackground.Load += frmBackground_Load;

                // Set up the global hooks
                actHook = new UserActivityHook();
                actHook.OnMouseActivity += actHook_OnMouseActivity;
                actHook.KeyDown += actHook_KeyDown;

                // Run the application
                Application.EnableVisualStyles();
                Application.Run(frmBackground);
            }
            catch(Exception x)
            {
                MessageBox.Show(x.Message, "Error",  MessageBoxButtons.OK , MessageBoxIcon.Error);
            }
        }