Skip to content

Commit

Permalink
v1.4 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
slinksoft committed Jan 16, 2023
1 parent 05e5eae commit 1cd4101
Show file tree
Hide file tree
Showing 23 changed files with 255 additions and 16 deletions.
106 changes: 92 additions & 14 deletions PublixRDPEnhancer/Form1.Designer.cs

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

98 changes: 97 additions & 1 deletion PublixRDPEnhancer/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,29 @@ private static extern string SHGetKnownFolderPath(

int ver, rev;

// AutoClick vars
int acInterval, acIntervalDis;
long acElapsed;
bool acEnabled;
Random r = new Random();
Stopwatch sw = new Stopwatch();

// Mouse Click DLL imports

[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);
//Mouse actions
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
private const int MOUSEEVENTF_RIGHTUP = 0x10;

public mCanvas()
{
InitializeComponent();

ver = 1;
rev = 1;
rev = 4;
versionDisplay.Text = "Version: " + ver + "." + rev;

// title logic
Expand Down Expand Up @@ -153,6 +170,78 @@ private void checkRDP_Tick(object sender, EventArgs e)
estSessionDis.ForeColor = System.Drawing.Color.Green;
}
}

private void killProcess_Click(object sender, EventArgs e)
{
foreach (var p in Process.GetProcessesByName("mstsc"))
{
p.Kill();
}
}

private void helpAutoClick_Click(object sender, EventArgs e)
{
MessageBox.Show(Properties.Resources.autoClickHelp, "Auto Click Help");
}



private void ACButton_Click(object sender, EventArgs e)
{
if (!acEnabled)
{
acEnabled = true;
ACButton.Text = Properties.Resources.stopAC;
clickTimerDis.Visible = true;

// set initial interval
acInterval = r.Next(10000, 60001); // between 10000 ms to 60001 (exclusive so 60000) ms ; or 10 to 60 seconds
acIntervalDis = acInterval;
autoClickTimer.Interval = acInterval;

// start the timers
autoClickTDisplay.Start();
autoClickTimer.Start();
sw.Start();

}
else if (acEnabled)
{
acEnabled = false;
ACButton.Text = Properties.Resources.startAC;
clickTimerDis.Visible = false;

// stop the timers
autoClickTDisplay.Stop();
autoClickTimer.Stop();
sw.Stop();
sw.Restart();

}
}

private void autoClickTimer_Tick(object sender, EventArgs e)
{
// replicate click
LeftMouseClick(Cursor.Position.X, Cursor.Position.Y);

// new interval and restart stop watch
acInterval = r.Next(10000, 60001); // between 10000 ms to 60001 (exclusive so 60000) ms ; or 10 to 60 seconds
autoClickTimer.Interval = acInterval;
sw.Stop();
sw.Restart();
sw.Start();

}

private void autoClickTDisplay_Tick(object sender, EventArgs e)
{
acElapsed = ((acInterval / 1000) - (sw.ElapsedMilliseconds / 1000));

if (acElapsed != -1) // prevent display timer from going to negative territory
clickTimerDis.Text = "Next Click In:\n" + ((acInterval/1000) - (sw.ElapsedMilliseconds/1000)) + " seconds";
}

public void AppendText(RichTextBox box, string text, Color color)
{
box.SelectionStart = box.TextLength;
Expand All @@ -162,5 +251,12 @@ public void AppendText(RichTextBox box, string text, Color color)
box.AppendText(text);
box.SelectionColor = box.ForeColor;
}

// simulates mouse click
public static void LeftMouseClick(int xpos, int ypos)
{
mouse_event(MOUSEEVENTF_LEFTDOWN, (uint)xpos, (uint)ypos, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, (uint)xpos, (uint)ypos, 0, 0);
}
}
}
11 changes: 10 additions & 1 deletion PublixRDPEnhancer/Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,22 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTipper.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>152, 17</value>
</metadata>
<data name="warning.Text" xml:space="preserve">
<value>WARNING: Clicking Connect will delete all RDP files in your Downloads directory except the latest one (not including RDP files within subfolders of the directory). This program will modify the RDP file contents to set your desired settings, then automatically open and establish the RDP session.

Make sure you have downloaded your machine's latest RDP Session File or an error may occur!</value>
</data>
<metadata name="checkRDP.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
<value>47, 17</value>
</metadata>
<metadata name="autoClickTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>269, 27</value>
</metadata>
<metadata name="autoClickTDisplay.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>393, 35</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
Expand Down
Loading

0 comments on commit 1cd4101

Please sign in to comment.