2

I'd like to play a video when no mouse action is launch and the cursor is not moving for 10 seconds. I tried this code:

private void dispatcherTimer_Tick(object sender, EventArgs e)
        {
            Test t = new Test();
            t.Show();
        }

        public void declencher() {
            try
            {
                while (Mouse.Captured != null)
                {
                    dispatcherTimer = new DispatcherTimer();
                    dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
                    dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 12);
                    dispatcherTimer.Start();
                    MessageBox.Show("hhh");
                }
            }
            catch { }


        }

I'd like to know how can i test this condition in WPF and what is the best method to do it

Lamloumi Afif
  • 8,941
  • 26
  • 98
  • 191

2 Answers2

2

check this code

 if (button1.Content.Equals("Play"))
            {
                button1.Content = "Pause";
                mediaElement1.Play();
            }
            else
            {
                button1.Content = "Play";
                mediaElement1.Pause();
            }
Akshay Joy
  • 1,765
  • 1
  • 14
  • 23
  • No i mean the condition ( testing no mouse action and no cursor action is launched in 10 secondes ) to show another window that contains the video – Lamloumi Afif May 13 '13 at 08:30
  • you mean to say App has to wait for 10 Second to Load the Video, – Akshay Joy May 13 '13 at 08:33
  • try with this Test for Mouse.Captured!= null. – Akshay Joy May 13 '13 at 08:35
  • i have a wpf application is running . When user didn't done any thing in 10 seconds( cursor and mouse not moving) another window appears and cover the first one and it contains for example a full screen video – Lamloumi Afif May 13 '13 at 08:36
0

There are multiple ways and seems all are discussed in other threads The methods are using combination of ,InputManager.Current.PreProcessInput = timer,ApplicationIdle event dispatcher or Win32 calls. If you didn't try these, please do.

WPF inactivity and activity, Getting inactivity/idle time in a WPF application application http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/811f5706-b9d7-414c-a590-cb9f6108b564 http://weblogs.asp.net/jdanforth/archive/2011/03/19/detecting-idle-time-with-global-mouse-and-keyboard-hooks-in-wpf.aspx

I hope you are already aware of playing videos in WPF.

Community
  • 1
  • 1
Joy George Kunjikkuru
  • 1,495
  • 13
  • 27