Skip to content

Commit

Permalink
v4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
kgsensei committed Oct 19, 2023
1 parent fec2db2 commit db75237
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 62 deletions.
Binary file modified .vs/NitroTypeHack2/v17/.suo
Binary file not shown.
83 changes: 42 additions & 41 deletions NitroTypeHack2/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,14 @@ public async static void simulateTypingText(
if (Globals.useNitros)
{
var words = text.Split('\u00A0');
int longest = words.Max(w => w.Length);
words[longest] = "ʜ";
string longest = words.OrderByDescending(n => n.Length).First();
text = string.Join(" ", words);
text = ReplaceFirst(text, longest, "ʜ");
}

char[] letters = text.Replace("\u00A0", " ").ToCharArray();
var gen = new Random();

if (Globals.randomize)
{
accuracy -= (int)gen.NextDouble() * 20;
typingDelay -= (int)gen.NextDouble() * 20;
}

int toMiss = (int)Math.Floor(letters.Length * ((decimal)(100 - accuracy) / 100));
int maxIndex = (int)Math.Floor(letters.Length / (decimal)(toMiss + 1));
int index = 0;
Expand All @@ -60,57 +54,64 @@ public async static void simulateTypingText(
}
else
{
textEntry(letter, webview2);
string args;
if (letter == 32)
{
args = @"{""type"": ""rawKeyDown"", ""windowsVirtualKeyCode"": 32, ""unmodifiedText"": "" "", ""text"": "" ""}";
_ = await webview2.CoreWebView2.CallDevToolsProtocolMethodAsync(
"Input.dispatchKeyEvent",
args
);

args = @"{""type"": ""keyUp"", ""windowsVirtualKeyCode"": 32, ""unmodifiedText"": "" "", ""text"": "" ""}";
_ = await webview2.CoreWebView2.CallDevToolsProtocolMethodAsync(
"Input.dispatchKeyEvent",
args
);
}
else
{
args = @"{""type"": ""char"", ""text"": """ + letter + @"""}";
_ = await webview2.CoreWebView2.CallDevToolsProtocolMethodAsync(
"Input.dispatchKeyEvent",
args
);
}
}

if (index == maxIndex)
{
textEntry('+', webview2);
string args = @"{""type"": ""char"", ""text"": ""+""}";
_ = await webview2.CoreWebView2.CallDevToolsProtocolMethodAsync(
"Input.dispatchKeyEvent",
args
);
index = 0;
}
else
{
index = index + 1;
}

await Task.Delay(typingDelay);

if (Globals.autoGame)
if(!Globals.godMode)
{
await Task.Delay(gen.Next(4900, 6100));
webview2.Reload();
await Task.Delay((int)(Math.Sin(index) + typingDelay));
}
}

isCheatRunning = false;
if (Globals.autoGame)
{
await Task.Delay(gen.Next(4900, 6100));
webview2.Reload();
}

isCheatRunning = false;
}

private async static void textEntry(
char letter,
Microsoft.Web.WebView2.Wpf.WebView2 webview2)
public static string ReplaceFirst(string input, string find, string replace)
{
string args;
if (letter == 32)
{
args = @"{""type"": ""rawKeyDown"", ""windowsVirtualKeyCode"": 32, ""unmodifiedText"": "" "", ""text"": "" ""}";
_ = await webview2.CoreWebView2.CallDevToolsProtocolMethodAsync(
"Input.dispatchKeyEvent",
args
);

args = @"{""type"": ""keyUp"", ""windowsVirtualKeyCode"": 32, ""unmodifiedText"": "" "", ""text"": "" ""}";
_ = await webview2.CoreWebView2.CallDevToolsProtocolMethodAsync(
"Input.dispatchKeyEvent",
args
);
} else
{
args = @"{""type"": ""char"", ""text"": """ + letter + @"""}";
_ = await webview2.CoreWebView2.CallDevToolsProtocolMethodAsync(
"Input.dispatchKeyEvent",
args
);
}
var first = input.IndexOf(find);
return input.Substring(0, first) + replace + input.Substring(first + find.Length);
}
}
}
23 changes: 10 additions & 13 deletions NitroTypeHack2/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,47 +17,44 @@
<ColumnDefinition Width="220" MinWidth="220"/>
</Grid.ColumnDefinitions>


<Wpf:WebView2 Grid.Column="0" Name="webview2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
Source="https://nitrotype.com" Margin="0,0,0,0" WebMessageReceived="Webview2_WebMessageReceived"/>


<Button Grid.Column="1" Content="Start Cheat" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top"
Width="200" Height="37" FontSize="16" Click="button_start_cheat" Name="startCheatBtn" Background="#FF1E1E23"
Foreground="White" BorderBrush="#FF323237" FontFamily="Arial"/>

<Slider Grid.Column="1" HorizontalAlignment="Left" Margin="10,52,0,0" VerticalAlignment="Top" Width="200" Value="100"
Maximum="350" Minimum="30" ValueChanged="slider_change_speed" Name="cheatTypeSpeedSlider" Panel.ZIndex="99"
Foreground="White"/>

<Label Grid.Column="1" Content="[Cheat Typing Speed]" HorizontalAlignment="Left" Margin="10,64,0,0" VerticalAlignment="Top"
Height="34" Width="200" FontSize="15" Foreground="White"/>


<Slider Grid.Column="1" HorizontalAlignment="Left" Margin="10,98,0,0" VerticalAlignment="Top" Width="200" Value="100"
Maximum="100" Minimum="0" x:Name="cheatTypeAccSlider" Panel.ZIndex="99"
Foreground="White"/>
Foreground="White" ValueChanged="slider_change_accuracy"/>

<Label Grid.Column="1" Content="[Cheat Typing Accuracy]" HorizontalAlignment="Left" Margin="10,110,0,0" VerticalAlignment="Top"
Height="34" Width="200" FontSize="15" Foreground="White"/>


<CheckBox Grid.Column="1" Content="Auto Start" HorizontalAlignment="Left" Margin="10,180,0,0" VerticalAlignment="Top"
Height="40" Width="200" FontSize="16" Background="#FF646469" BorderBrush="#FF28282D" Foreground="White" IsChecked="True"
Checked="button_AutoStartOn" Unchecked="button_AutoStartOff"/>

<CheckBox Grid.Column="1" Content="God Mode" HorizontalAlignment="Left" Margin="10,215,0,0" VerticalAlignment="Top"
Height="40" Width="200" FontSize="16" Background="#FF646469" Name="button_GodMode"
BorderBrush="#FF28282D" Foreground="White" Checked="button_GodModeEnabled" Unchecked="button_GodModeDisabled"/>

<CheckBox Grid.Column="1" Content="Random Variations" HorizontalAlignment="Left" Margin="10,250,0,0" VerticalAlignment="Top"
Height="40" Width="200" FontSize="16" Background="#FF646469" BorderBrush="#FF28282D" Foreground="White"/>

<CheckBox Grid.Column="1" Content="Auto Game" HorizontalAlignment="Left" Margin="10,285,0,0" VerticalAlignment="Top"

<CheckBox Grid.Column="1" Content="Auto Game" HorizontalAlignment="Center" Margin="0,250,0,0" VerticalAlignment="Top"
Height="40" Width="200" FontSize="16" Background="#FF646469" BorderBrush="#FF28282D" Foreground="White"
Checked="button_AutoGameOn" Unchecked="button_AutoGameOff" Name="button_AutoGame"/>
<CheckBox Grid.Column="1" Content="Use Nitros" HorizontalAlignment="Left" Margin="10,320,0,0" VerticalAlignment="Top"

<CheckBox Grid.Column="1" Content="Use Nitros" HorizontalAlignment="Center" Margin="0,285,0,0" VerticalAlignment="Top"
Height="40" Width="200" FontSize="16" Background="#FF646469" BorderBrush="#FF28282D" Foreground="White"
Checked="button_UseNitrosOn" Unchecked="button_UseNitrosOff" Name="button_UseNitros"/>
</Grid>
Expand Down
11 changes: 10 additions & 1 deletion NitroTypeHack2/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Globals
public static int accuracyLevel { get; set; } = 100;
public static bool godMode { get; set; } = false;
public static bool autoStart { get; set; } = true;
public static bool randomize { get; set; } = false;
public static bool autoGame { get; set; } = false;
public static bool useNitros { get; set; } = false;
}
Expand Down Expand Up @@ -98,6 +97,16 @@ private void slider_change_speed(
}
}

private void slider_change_accuracy(
object sender,
RoutedPropertyChangedEventArgs<double> e)
{
if(!Globals.godMode && !App.isCheatRunning)
{
Globals.accuracyLevel = Convert.ToInt32(e.NewValue);
}
}

private void button_GodModeEnabled(object sender, RoutedEventArgs e)
{
if (!App.isCheatRunning)
Expand Down
20 changes: 13 additions & 7 deletions NitroTypeHack2/obj/Debug/MainWindow.g.i.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma checksum "..\..\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "94DC58AA03F027D8AED34D4E7E0EC5C8919F50DA15E05A57345462AE5BF5A082"
#pragma checksum "..\..\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "4168BE28D81E7265BF76E10A1389DCF1249E5DAFAD983E04A946BE5A8004ED94"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
Expand Down Expand Up @@ -82,15 +82,15 @@ public partial class MainWindow : System.Windows.Window, System.Windows.Markup.I
#line hidden


#line 58 "..\..\MainWindow.xaml"
#line 55 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.CheckBox button_AutoGame;

#line default
#line hidden


#line 62 "..\..\MainWindow.xaml"
#line 59 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.CheckBox button_UseNitros;

Expand Down Expand Up @@ -156,6 +156,12 @@ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object
return;
case 4:
this.cheatTypeAccSlider = ((System.Windows.Controls.Slider)(target));

#line 39 "..\..\MainWindow.xaml"
this.cheatTypeAccSlider.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler<double>(this.slider_change_accuracy);

#line default
#line hidden
return;
case 5:

Expand Down Expand Up @@ -189,13 +195,13 @@ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object
case 7:
this.button_AutoGame = ((System.Windows.Controls.CheckBox)(target));

#line 58 "..\..\MainWindow.xaml"
#line 55 "..\..\MainWindow.xaml"
this.button_AutoGame.Checked += new System.Windows.RoutedEventHandler(this.button_AutoGameOn);

#line default
#line hidden

#line 58 "..\..\MainWindow.xaml"
#line 55 "..\..\MainWindow.xaml"
this.button_AutoGame.Unchecked += new System.Windows.RoutedEventHandler(this.button_AutoGameOff);

#line default
Expand All @@ -204,13 +210,13 @@ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object
case 8:
this.button_UseNitros = ((System.Windows.Controls.CheckBox)(target));

#line 62 "..\..\MainWindow.xaml"
#line 59 "..\..\MainWindow.xaml"
this.button_UseNitros.Checked += new System.Windows.RoutedEventHandler(this.button_UseNitrosOn);

#line default
#line hidden

#line 62 "..\..\MainWindow.xaml"
#line 59 "..\..\MainWindow.xaml"
this.button_UseNitros.Unchecked += new System.Windows.RoutedEventHandler(this.button_UseNitrosOff);

#line default
Expand Down

0 comments on commit db75237

Please sign in to comment.