-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ShayanFiroozi/dev
Dev
- Loading branch information
Showing
8 changed files
with
261 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,36 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Windows.Forms; | ||
|
||
namespace FluentTypeSimulator.BackEnd | ||
{ | ||
|
||
|
||
internal static class Parser | ||
{ | ||
public static char[] ParseString(string inputData) | ||
public static char[] StringToCharArray(string inputData) | ||
{ | ||
if (string.IsNullOrWhiteSpace(inputData)) | ||
{ | ||
throw new ArgumentException($"'{nameof(inputData)}' cannot be null or whitespace.", nameof(inputData)); | ||
} | ||
|
||
return inputData.ToCharArray().Where(c => c != '\r').ToArray(); | ||
} | ||
|
||
|
||
|
||
} | ||
public static string[] StringToStringArray(string inputData) | ||
{ | ||
if (string.IsNullOrWhiteSpace(inputData)) | ||
{ | ||
throw new ArgumentException($"'{nameof(inputData)}' cannot be null or whitespace.", nameof(inputData)); | ||
} | ||
|
||
return inputData.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); | ||
} | ||
|
||
|
||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace FluentTypeSimulator.BackEnd | ||
{ | ||
internal static class TypeSimulator | ||
{ | ||
|
||
|
||
public static async Task SimulateTyping(string TextToType, int KeyPressDelayInMilliSeconds, int NewLineDelayInMilliSedonds) | ||
{ | ||
char[] CharsToType = Parser.StringToCharArray(TextToType); | ||
|
||
if (CharsToType.Length == 0) | ||
{ | ||
throw new Exception("No word to type !"); | ||
} | ||
|
||
foreach (char character in CharsToType) | ||
{ | ||
await SimulateKeyPress(character, NewLineDelayInMilliSedonds); | ||
|
||
if (KeyPressDelayInMilliSeconds > 0) | ||
{ | ||
await Task.Delay(KeyPressDelayInMilliSeconds); | ||
} | ||
} | ||
|
||
} | ||
|
||
private static async Task SimulateKeyPress(char character, int NewLineDelayInMilliSedonds) | ||
{ | ||
|
||
switch (character) | ||
{ | ||
case '\n': | ||
// Simulate pressing Enter | ||
KeyBoardSimulator.PressEnter(); | ||
await Task.Delay(NewLineDelayInMilliSedonds); | ||
break; | ||
|
||
case ' ': | ||
// Simulate pressing Space | ||
KeyBoardSimulator.PressSpace(); | ||
break; | ||
default: | ||
// Simulate other character | ||
|
||
if (char.IsLetter(character) || char.IsDigit(character) || char.IsNumber(character)) | ||
{ | ||
// Letter or number characters | ||
SendKeys.Send(character.ToString()); | ||
} | ||
else | ||
{ | ||
// Special characters | ||
KeyBoardSimulator.PressSpecialCharacter(character.ToString()); | ||
} | ||
|
||
break; | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace FluentTypeSimulator.BackEnd | ||
{ | ||
internal static class TypeSimulatorCopyPasteMode | ||
{ | ||
|
||
|
||
public static async Task StartCopyPasting(string TextToCopyPaste, int NewLineDelayInMilliSedonds) | ||
{ | ||
string[] LinesToCopyPaste = Parser.StringToStringArray(TextToCopyPaste); | ||
|
||
if (LinesToCopyPaste.Length == 0) | ||
{ | ||
throw new Exception("No lines to copy/paste !"); | ||
} | ||
|
||
foreach (string line in LinesToCopyPaste) | ||
{ | ||
// Handle the wmpty lines | ||
if (string.IsNullOrEmpty(line)) | ||
{ | ||
KeyBoardSimulator.PressEnter(); | ||
|
||
if (NewLineDelayInMilliSedonds > 0) | ||
{ | ||
await Task.Delay(NewLineDelayInMilliSedonds); | ||
} | ||
continue; | ||
} | ||
|
||
|
||
// Put the line to clipboard | ||
Clipboard.Clear(); | ||
Clipboard.SetText(line); | ||
|
||
// Paste Data from clipboard | ||
KeyBoardSimulator.PressCTRL_V(); | ||
|
||
|
||
// Go to the new linw | ||
KeyBoardSimulator.PressEnter(); | ||
|
||
if (NewLineDelayInMilliSedonds > 0) | ||
{ | ||
await Task.Delay(NewLineDelayInMilliSedonds); | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# FluentTypeSimulator Change Log : | ||
|
||
|
||
Test | ||
|
||
## ✔ 1.0 | ||
* Change log created ! |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.