Skip to content

Commit 7455095

Browse files
committed
Removed zen mode and about dialog, added interval
1 parent d1e91c7 commit 7455095

File tree

5 files changed

+99
-109
lines changed

5 files changed

+99
-109
lines changed

MainForm.Designer.cs

Lines changed: 45 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MainForm.cs

Lines changed: 32 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -24,85 +24,55 @@ public partial class MainForm : Form
2424

2525
protected bool zig = true;
2626

27-
public MainForm ()
27+
public MainForm()
2828
{
29-
this.InitializeComponent ();
29+
this.InitializeComponent();
3030
}
3131

32-
private void jiggleTimer_Tick (object sender, EventArgs e)
32+
private void jiggleTimer_Tick(object sender, EventArgs e)
3333
{
34-
// jiggle
35-
if (this.cbZenJiggle.Checked)
36-
Jiggler.Jiggle (0, 0);
37-
else
34+
if (this.zig)
3835
{
39-
if (this.zig)
40-
Jiggler.Jiggle (4, 4);
41-
else // zag
42-
{
43-
// I really don't know why this needs to be less to stay in the same
44-
// place; if I was likely to use it again, then I'd worry.
45-
Jiggler.Jiggle (-4, -4);
46-
}
36+
Jiggler.Jiggle(4, 4);
37+
this.jiggleTimer.Interval = 500;
38+
}
39+
else // zag
40+
{
41+
// I really don't know why this needs to be less to stay in the same
42+
// place; if I was likely to use it again, then I'd worry.
43+
Jiggler.Jiggle(-4, -4);
44+
this.jiggleTimer.Interval = Program.JiggleInterval * 60 * 1000;
4745
}
4846

4947
this.zig = !this.zig;
5048
}
5149

52-
private void cbEnabled_CheckedChanged (object sender, EventArgs e)
50+
private void updateJiggleTimer()
5351
{
54-
this.jiggleTimer.Enabled = this.cbEnabled.Checked;
52+
this.jiggleTimer.Interval = Program.JiggleInterval * 60 * 1000;
5553
}
5654

57-
private void cmdAbout_Click (object sender, EventArgs e)
55+
private void cbEnabled_CheckedChanged(object sender, EventArgs e)
5856
{
59-
using (var a = new AboutBox ())
60-
a.ShowDialog ();
57+
updateJiggleTimer();
58+
this.jiggleTimer.Enabled = this.cbEnabled.Checked;
6159
}
6260

63-
private void MainForm_Load (object sender, EventArgs e)
61+
private void cmdAbout_Click(object sender, EventArgs e)
6462
{
65-
try
66-
{
67-
RegistryKey key = Registry.CurrentUser.CreateSubKey (@"Software\Arkane Systems\MouseJiggle",
68-
RegistryKeyPermissionCheck.ReadWriteSubTree);
69-
var zen = (int) key.GetValue ("ZenJiggleEnabled", 0);
70-
71-
if (zen == 0)
72-
this.cbZenJiggle.Checked = false;
73-
else
74-
this.cbZenJiggle.Checked = true;
75-
}
76-
catch (Exception)
77-
{
78-
// Ignore any problems - non-critical operation.
79-
}
80-
81-
if (Program.ZenJiggling)
82-
this.cbZenJiggle.Checked = true;
63+
using (var a = new AboutBox())
64+
a.ShowDialog();
65+
}
8366

67+
private void MainForm_Load(object sender, EventArgs e)
68+
{
8469
if (Program.StartJiggling)
8570
this.cbEnabled.Checked = true;
8671

8772
if (Program.StartMinimized)
8873
this.cmdToTray_Click(this, null);
89-
}
9074

91-
private void cbZenJiggle_CheckedChanged (object sender, EventArgs e)
92-
{
93-
try
94-
{
95-
RegistryKey key = Registry.CurrentUser.CreateSubKey (@"Software\Arkane Systems\MouseJiggle",
96-
RegistryKeyPermissionCheck.ReadWriteSubTree);
97-
if (this.cbZenJiggle.Checked)
98-
key.SetValue ("ZenJiggleEnabled", 1);
99-
else
100-
key.SetValue ("ZenJiggleEnabled", 0);
101-
}
102-
catch (Exception)
103-
{
104-
// Ignore any problems - non-critical operation.
105-
}
75+
this.intervalUpDown.Value = Program.JiggleInterval;
10676
}
10777

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

120-
private void nifMin_DoubleClick (object sender, EventArgs e)
90+
private void nifMin_DoubleClick(object sender, EventArgs e)
12191
{
12292
// restore the window
12393
this.Visible = true;
@@ -128,5 +98,11 @@ private void nifMin_DoubleClick (object sender, EventArgs e)
12898
// hide tray icon
12999
this.nifMin.Visible = false;
130100
}
101+
102+
private void intervalUpDown_ValueChanged(object sender, EventArgs e)
103+
{
104+
Program.JiggleInterval = (int) ((NumericUpDown)sender).Value;
105+
updateJiggleTimer();
106+
}
131107
}
132108
}

MainForm.resx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,23 +112,23 @@
112112
<value>2.0</value>
113113
</resheader>
114114
<resheader name="reader">
115-
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
115+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116116
</resheader>
117117
<resheader name="writer">
118-
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
118+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120-
<metadata name="jiggleTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
120+
<metadata name="jiggleTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121121
<value>17, 17</value>
122122
</metadata>
123-
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
123+
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
124124
<data name="cmdToTray.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
125125
<value>
126126
R0lGODlhEAAQAIMLAJLNXpDEaZPNX4/NU5bUWJnXWpDNVIvFWXyuWmOPRf///////wAAAAAAAAAAAAAA
127127
ACH/C05FVFNDQVBFMi4wAwEBAAAh+QQBAAALACwAAAAAEAAQAAAIRwAXCBxIsKDBgwgTIlTAsKFCBQki
128128
JlDwMMEAABMXMkxgAKPDghAjEgggkaJBiAAKCDiQcWECAAhaJgxpUuEChjZz6tzJ02BAADs=
129129
</value>
130130
</data>
131-
<metadata name="nifMin.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
131+
<metadata name="nifMin.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
132132
<value>129, 17</value>
133133
</metadata>
134134
<data name="nifMin.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">

Program.cs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ namespace ArkaneSystems.MouseJiggle
2020
internal static class Program
2121
{
2222
public static bool StartJiggling = false;
23-
public static bool ZenJiggling = false;
2423
public static bool StartMinimized = false;
24+
public static int JiggleInterval = 1; // Minutes
2525

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

44-
if ((System.String.Compare (arg.ToUpperInvariant (), "--ZEN", System.StringComparison.Ordinal) == 0) ||
45-
(System.String.Compare (arg.ToUpperInvariant (), "-Z", System.StringComparison.Ordinal) == 0))
46-
ZenJiggling = true;
41+
if ((System.String.Compare(arg.ToUpperInvariant(), "--JIGGLE", System.StringComparison.Ordinal) == 0) ||
42+
(System.String.Compare(arg.ToUpperInvariant(), "-J", System.StringComparison.Ordinal) == 0))
43+
StartJiggling = true;
4744

4845
if (
49-
(System.String.Compare (arg.ToUpperInvariant (), "--MINIMIZED", System.StringComparison.Ordinal) ==
50-
0) ||
51-
(System.String.Compare (arg.ToUpperInvariant (), "-M", System.StringComparison.Ordinal) == 0))
46+
(System.String.Compare(arg.ToUpperInvariant(), "--MINIMIZED", System.StringComparison.Ordinal) == 0) ||
47+
(System.String.Compare(arg.ToUpperInvariant(), "-M", System.StringComparison.Ordinal) == 0))
5248
StartMinimized = true;
49+
50+
if (
51+
((System.String.Compare(arg.ToUpperInvariant(), "--INTERVAL", System.StringComparison.Ordinal) == 0) ||
52+
(System.String.Compare(arg.ToUpperInvariant(), "-I", System.StringComparison.Ordinal) == 0)) &&
53+
i+1 < args.Length)
54+
JiggleInterval = int.Parse(args[++i]);
5355
}
5456

5557
Application.EnableVisualStyles ();

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
NOTE: I removed Zen Mode and added an Interval setting in this fork.
2+
13
mousejiggler
24
============
35

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

18-
The 'Zen jiggle?' checkbox enables a mode in which the pointer is jiggled 'virtually' - the system believes it
19-
to be moving and thus screen saver activation, etc., is prevented, but the pointer does not actually move.
20-
2120
To minimize Mouse Jiggler to the system tray, click the button marked with a green, down-pointing arrow.
2221

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

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

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

0 commit comments

Comments
 (0)