tags:

views:

230

answers:

2

I'm writing an application for personal use that will track how often I reach for the mouse, and will keep a counter of how long I've gone mouseless. When I use the mouse, I would like it to shake my desktop workspace for a second as a negative reinforcement action.

The application is going to be called WristSlap and will be on github as soon as I have a version 0.1 ready.

+1  A: 

You could create a transparent window with a changing twirl shader effect.

I'm not sure that will solve your addiction to computers though.

Danny Varod
It's not the addiction to computers I'm trying to shake. I'm trying to make something that makes me use the mouse less often and use the keyboard more.
Scott Muc
Then try a Logitech dinovo mini.
Danny Varod
+4  A: 

Danny is onto something with the transparent window idea. But it doesn't have to be transparent. You would have to accept some certain limitations though.

You would want to grab a screen shot of the desktop and apply it to a full screen WPF window. (Check out my blog for a handy FullScreenBehavior for WPF Window). Then you would just apply some epilepsy-inducing animation to a translate layout transform on the root element. This would give the effect of shaking. At the end the window could just close.

Since during the animation the coordinates of everything will be all over the place, you probably don't want to be bothered with trying to translate mouse clicks on the moving desktop to the underlying control. If the animation is short enough it won't matter because you won't have time to try to click anything while it is shaking.

For more realism you could look into using the DWM (Desktop Window Manager) to project a "live" view of the desktop but that's probably not worth it especially if you keep the animation very short.

I almost want to try this myself for fun.

I came up with this using a static image for now. It's ok but it could be improved.

<Image Source="Slide1.png" Stretch="UniformToFill">

<Image.Effect>
  <BlurEffect Radius="5" />
</Image.Effect>

<Image.RenderTransform>
  <TranslateTransform Y="0" X="0"/>
</Image.RenderTransform>

<Image.Triggers>
  <EventTrigger RoutedEvent="FrameworkElement.Loaded">
    <BeginStoryboard>
      <Storyboard RepeatBehavior="00:00:01" SpeedRatio="15">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)">
          <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="-10"/>
          <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0"/>
          <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="10"/>
          <SplineDoubleKeyFrame KeyTime="00:00:00.7000000" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)">
          <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="-10"/>
          <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="-10"/>
          <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="10"/>
          <SplineDoubleKeyFrame KeyTime="00:00:00.7000000" Value="10"/>
          <SplineDoubleKeyFrame KeyTime="00:00:00.9000000" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
      </Storyboard>
    </BeginStoryboard>
  </EventTrigger>
</Image.Triggers>

</Image>
Josh Einstein
This actually sounds a bit evil (no offense, it is interesting technically speaking). Imagine fake antivirus applications that do this to prevent you from leaving their windows.
Riddari
Well that's why Silverlight web apps won't let you make full screen windows that accept keyboard input. But this is about WPF which has full access to the Windows API so showing a full screen window is not a concern. If a WPF app is running on your desktop then it can already do whatever it wants. That's what Control+Alt+Delete sequence is for.
Josh Einstein
FYI, Silverlight 4 will have some keyboard input capabilities in fullscreen mode.
Gabe
Only for locally installed apps with elevated permissions.
Josh Einstein