Skip to content

Commit

Permalink
Removed zen mode and about dialog, added interval
Browse files Browse the repository at this point in the history
  • Loading branch information
droidmonkey committed May 4, 2018
1 parent d1e91c7 commit 7455095
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 109 deletions.
76 changes: 45 additions & 31 deletions MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

88 changes: 32 additions & 56 deletions MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,85 +24,55 @@ public partial class MainForm : Form

protected bool zig = true;

public MainForm ()
public MainForm()
{
this.InitializeComponent ();
this.InitializeComponent();
}

private void jiggleTimer_Tick (object sender, EventArgs e)
private void jiggleTimer_Tick(object sender, EventArgs e)
{
// jiggle
if (this.cbZenJiggle.Checked)
Jiggler.Jiggle (0, 0);
else
if (this.zig)
{
if (this.zig)
Jiggler.Jiggle (4, 4);
else // zag
{
// I really don't know why this needs to be less to stay in the same
// place; if I was likely to use it again, then I'd worry.
Jiggler.Jiggle (-4, -4);
}
Jiggler.Jiggle(4, 4);
this.jiggleTimer.Interval = 500;
}
else // zag
{
// I really don't know why this needs to be less to stay in the same
// place; if I was likely to use it again, then I'd worry.
Jiggler.Jiggle(-4, -4);
this.jiggleTimer.Interval = Program.JiggleInterval * 60 * 1000;
}

this.zig = !this.zig;
}

private void cbEnabled_CheckedChanged (object sender, EventArgs e)
private void updateJiggleTimer()
{
this.jiggleTimer.Enabled = this.cbEnabled.Checked;
this.jiggleTimer.Interval = Program.JiggleInterval * 60 * 1000;
}

private void cmdAbout_Click (object sender, EventArgs e)
private void cbEnabled_CheckedChanged(object sender, EventArgs e)
{
using (var a = new AboutBox ())
a.ShowDialog ();
updateJiggleTimer();
this.jiggleTimer.Enabled = this.cbEnabled.Checked;
}

private void MainForm_Load (object sender, EventArgs e)
private void cmdAbout_Click(object sender, EventArgs e)
{
try
{
RegistryKey key = Registry.CurrentUser.CreateSubKey (@"Software\Arkane Systems\MouseJiggle",
RegistryKeyPermissionCheck.ReadWriteSubTree);
var zen = (int) key.GetValue ("ZenJiggleEnabled", 0);

if (zen == 0)
this.cbZenJiggle.Checked = false;
else
this.cbZenJiggle.Checked = true;
}
catch (Exception)
{
// Ignore any problems - non-critical operation.
}

if (Program.ZenJiggling)
this.cbZenJiggle.Checked = true;
using (var a = new AboutBox())
a.ShowDialog();
}

private void MainForm_Load(object sender, EventArgs e)
{
if (Program.StartJiggling)
this.cbEnabled.Checked = true;

if (Program.StartMinimized)
this.cmdToTray_Click(this, null);
}

private void cbZenJiggle_CheckedChanged (object sender, EventArgs e)
{
try
{
RegistryKey key = Registry.CurrentUser.CreateSubKey (@"Software\Arkane Systems\MouseJiggle",
RegistryKeyPermissionCheck.ReadWriteSubTree);
if (this.cbZenJiggle.Checked)
key.SetValue ("ZenJiggleEnabled", 1);
else
key.SetValue ("ZenJiggleEnabled", 0);
}
catch (Exception)
{
// Ignore any problems - non-critical operation.
}
this.intervalUpDown.Value = Program.JiggleInterval;
}

private void cmdToTray_Click (object sender, EventArgs e)
Expand All @@ -117,7 +87,7 @@ private void cmdToTray_Click (object sender, EventArgs e)
this.nifMin.Visible = true;
}

private void nifMin_DoubleClick (object sender, EventArgs e)
private void nifMin_DoubleClick(object sender, EventArgs e)
{
// restore the window
this.Visible = true;
Expand All @@ -128,5 +98,11 @@ private void nifMin_DoubleClick (object sender, EventArgs e)
// hide tray icon
this.nifMin.Visible = false;
}

private void intervalUpDown_ValueChanged(object sender, EventArgs e)
{
Program.JiggleInterval = (int) ((NumericUpDown)sender).Value;
updateJiggleTimer();
}
}
}
10 changes: 5 additions & 5 deletions MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,23 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="jiggleTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="jiggleTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="cmdToTray.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
R0lGODlhEAAQAIMLAJLNXpDEaZPNX4/NU5bUWJnXWpDNVIvFWXyuWmOPRf///////wAAAAAAAAAAAAAA
ACH/C05FVFNDQVBFMi4wAwEBAAAh+QQBAAALACwAAAAAEAAQAAAIRwAXCBxIsKDBgwgTIlTAsKFCBQki
JlDwMMEAABMXMkxgAKPDghAjEgggkaJBiAAKCDiQcWECAAhaJgxpUuEChjZz6tzJ02BAADs=
</value>
</data>
<metadata name="nifMin.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="nifMin.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>129, 17</value>
</metadata>
<data name="nifMin.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
Expand Down
26 changes: 14 additions & 12 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ namespace ArkaneSystems.MouseJiggle
internal static class Program
{
public static bool StartJiggling = false;
public static bool ZenJiggling = false;
public static bool StartMinimized = false;
public static int JiggleInterval = 1; // Minutes

/// <summary>
/// The main entry point for the application.
Expand All @@ -34,22 +34,24 @@ private static void Main (string[] args)
if (instance.WaitOne(0, false))
{
// Check for command-line switches.
foreach (string arg in args)
for (int i=0; i < args.Length; ++i)
{
if ((System.String.Compare (arg.ToUpperInvariant (), "--JIGGLE", System.StringComparison.Ordinal) ==
0) ||
(System.String.Compare (arg.ToUpperInvariant (), "-J", System.StringComparison.Ordinal) == 0))
StartJiggling = true;
string arg = args[i];

if ((System.String.Compare (arg.ToUpperInvariant (), "--ZEN", System.StringComparison.Ordinal) == 0) ||
(System.String.Compare (arg.ToUpperInvariant (), "-Z", System.StringComparison.Ordinal) == 0))
ZenJiggling = true;
if ((System.String.Compare(arg.ToUpperInvariant(), "--JIGGLE", System.StringComparison.Ordinal) == 0) ||
(System.String.Compare(arg.ToUpperInvariant(), "-J", System.StringComparison.Ordinal) == 0))
StartJiggling = true;

if (
(System.String.Compare (arg.ToUpperInvariant (), "--MINIMIZED", System.StringComparison.Ordinal) ==
0) ||
(System.String.Compare (arg.ToUpperInvariant (), "-M", System.StringComparison.Ordinal) == 0))
(System.String.Compare(arg.ToUpperInvariant(), "--MINIMIZED", System.StringComparison.Ordinal) == 0) ||
(System.String.Compare(arg.ToUpperInvariant(), "-M", System.StringComparison.Ordinal) == 0))
StartMinimized = true;

if (
((System.String.Compare(arg.ToUpperInvariant(), "--INTERVAL", System.StringComparison.Ordinal) == 0) ||
(System.String.Compare(arg.ToUpperInvariant(), "-I", System.StringComparison.Ordinal) == 0)) &&
i+1 < args.Length)
JiggleInterval = int.Parse(args[++i]);
}

Application.EnableVisualStyles ();
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
NOTE: I removed Zen Mode and added an Interval setting in this fork.

mousejiggler
============

Expand All @@ -15,16 +17,12 @@ Simply run the MouseJiggle.exe included in the release .zip file. Check the "Ena
jiggling the mouse pointer; uncheck it to stop. The jiggle is slight enough that you should be able to use the
computer normally even with jiggling enabled.

The 'Zen jiggle?' checkbox enables a mode in which the pointer is jiggled 'virtually' - the system believes it
to be moving and thus screen saver activation, etc., is prevented, but the pointer does not actually move.

To minimize Mouse Jiggler to the system tray, click the button marked with a green, down-pointing arrow.

If you want to start the Mouse Jiggler with jiggling already enabled, run the MouseJiggle.exe with either the
-j or --jiggle command-line switch.

The "-z" / "--zen" command-line switch forces zen jiggling to be enabled for the current (and future) invocations
of MouseJiggler.
The "-i [minutes]" / "--interval [minutes]" (ie, -i 10) command-line argument allows you to set the number of minutes between jiggles.

(Added in 1.5+): The "-m" / "--minimized" command-like switch tells MouseJiggler to start already minimized.

Expand Down

0 comments on commit 7455095

Please sign in to comment.