Skip to content

Commit

Permalink
🐳 Huge Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
robiot committed Aug 2, 2021
1 parent a4c82e1 commit f075719
Show file tree
Hide file tree
Showing 10 changed files with 701 additions and 150 deletions.
8 changes: 8 additions & 0 deletions Alphaclicker/AlphaClicker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="GetCursorPos.xaml.cs">
<DependentUpon>GetCursorPos.xaml</DependentUpon>
</Compile>
<Compile Include="Registry.cs" />
<Compile Include="WinApi.cs" />
<Page Include="GetCursorPos.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="ChangeHotkey.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
10 changes: 6 additions & 4 deletions Alphaclicker/ChangeHotkey.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -413,19 +413,21 @@
VerticalAlignment="Center"
Height="36" Width="80"
Background="#808080"
Grid.Row="1" Margin="56,4,144,5" Click="okBtn_Click"/>
Grid.Row="1"
Margin="56,4,144,5"
Click="okBtn_Click"/>
<Button x:Name="cancelBtn"
Content="Cancel"
Foreground="White"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Height="36" Width="82"
Background="#808080"
Grid.Row="1" Margin="144,4,54,5" Click="cancelBtn_Click"/>
Grid.Row="1"
Margin="144,4,54,5"
Click="cancelBtn_Click"/>

</Grid>

<!-- Minimize button -->
</Grid>

</Border>
Expand Down
4 changes: 4 additions & 0 deletions Alphaclicker/ChangeHotkey.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ private void hotkeyWindow_PreviewKeyDown(object sender, KeyEventArgs e)
keyBox.AppendText(((char)i).ToString());
startBtn.IsEnabled = true;
key2 = i;
okBtn.IsEnabled = true;
break;
}
/* If function key */
Expand All @@ -81,6 +82,8 @@ private void hotkeyWindow_PreviewKeyDown(object sender, KeyEventArgs e)
keyBox.AppendText(CodeToSpecialKey(i));
startBtn.IsEnabled = true;
key2 = i;

okBtn.IsEnabled = true;
break;
}
/* If any extra keys (shift, ctrl, alt) */
Expand All @@ -103,6 +106,7 @@ private void hotkeyWindow_PreviewKeyDown(object sender, KeyEventArgs e)

private void startBtn_Click(object sender, RoutedEventArgs e)
{
okBtn.IsEnabled = false;
hasSpecKey = false;
startBtn.IsEnabled = false;
keyBox.Clear();
Expand Down
386 changes: 386 additions & 0 deletions Alphaclicker/GetCursorPos.xaml

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions Alphaclicker/GetCursorPos.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System;
using System.Threading;
using System.Windows;

namespace AlphaClicker
{
public partial class GetCursorPos: Window
{
public GetCursorPos()
{
InitializeComponent();
}

private bool enabled = true;
private void WindowHandler()
{
while (enabled)
{
Point location = WinApi.GetCursorPosition();

Dispatcher.Invoke((Action)(() =>
{
this.Left = location.X;
this.Top = location.Y;
xLbl.Content = $"X: {location.X}";
yLbl.Content = $"Y: {location.Y}";

}));
Thread.Sleep(20);
}
}

private void ClickHandler()
{
while (enabled)
{
if (WinApi.GetAsyncKeyState((int)VK.VK_LBUTTON) > 0||
WinApi.GetAsyncKeyState((int)VK.VK_ESCAPE) > 0)
{
enabled = false;
Dispatcher.Invoke((Action)(() =>
{
Point location = WinApi.GetCursorPosition();

((MainWindow)this.Owner).xBox.Text = location.X.ToString();
((MainWindow)this.Owner).yBox.Text = location.Y.ToString();
((MainWindow)this.Owner).WindowState = WindowState.Normal;
((MainWindow)this.Owner).keyEnabled = true;
Close();
}));
}
Thread.Sleep(200);
}
}

private void getCursorPosWindow_Loaded(object sender, RoutedEventArgs e)
{
((MainWindow)this.Owner).keyEnabled = false;

Thread windowHandler = new Thread(WindowHandler);
windowHandler.Start();

Thread clickhandler = new Thread(ClickHandler);
clickhandler.Start();
}
}
}
8 changes: 4 additions & 4 deletions Alphaclicker/KeyDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
public enum VK : int
{
// Commented out because it's not used
/*

VK_LBUTTON = 0x01,
VK_RBUTTON = 0x02,
/*VK_RBUTTON = 0x02,
VK_CANCEL = 0x03,
VK_MBUTTON = 0x04,
//
Expand All @@ -32,9 +32,9 @@ public enum VK : int
VK_FINAL = 0x18,
VK_HANJA = 0x19,
VK_KANJI = 0x19,
//
*/
VK_ESCAPE = 0x1B,
//
/*
VK_CONVERT = 0x1C,
VK_NONCONVERT = 0x1D,
VK_ACCEPT = 0x1E,
Expand Down
Loading

0 comments on commit f075719

Please sign in to comment.