Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot type uppercase symbols #30

Open
LeeeJoe opened this issue Jun 17, 2022 · 0 comments
Open

Cannot type uppercase symbols #30

LeeeJoe opened this issue Jun 17, 2022 · 0 comments

Comments

@LeeeJoe
Copy link

LeeeJoe commented Jun 17, 2022

Hi.
Cannot type uppercase symbols:

using Desktop.Robot;
using Desktop.Robot.Extensions;

using System.Text.RegularExpressions;

DoTask();

void DoTask()
{
    const string s1 = "~!@#$%^&*()_+{}|:\"<>?";
    const string s2 = "VaLeri+buHattI+2022  ~~ !! @@ ## $$ %% ^^ && ** (( )) __ ++ {{ }} || :: \"\" << >> ??";

    var robot = new Robot();
    robot.AutoDelay = 10;

    string s;
    Console.WriteLine("Hello world!\n");
    Console.WriteLine($"String to type 1:\n{s1}\n");
    Console.WriteLine($"String to type 2:\n{s2}\n");

    Task.Run(async () => 
    {
        await Task.Delay(1000);

        s = s1;
        robot.Type(s);
        robot.Type("  ");

        // Insert from clipboard
        robot.KeyDown(Key.Shift);
        robot.KeyPress(Key.Insert);
        robot.KeyPress(Key.Insert);
        robot.KeyPress(Key.Insert);
        robot.KeyUp(Key.Shift);

        robot.Type("  ");
        s = s2;

        for (int i = 0; i < s.Length; i++)
        {
            if (IsUpperSymbol(s[i]) || Regex.IsMatch(s[i].ToString(), "[A-Z]"))
            {
                robot.KeyDown(Key.Shift);
                robot.KeyPress(s[i]);
                robot.KeyUp(Key.Shift);
            }
            else
            {
                robot.KeyPress(s[i]);
            }
        }

        robot.KeyPress(Key.Enter);
    });

    s = Console.ReadLine();

    Console.WriteLine($"\nEntered string is:\n{s}");
}

bool IsUpperSymbol(char ch)
{
    bool res = false;
    char[] chars = { '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '{', '}', '|', ':', '"', '<', '>', '?' };

    foreach (var c in chars)
    {
        if (c == ch)
        {
            res = true;
            break;
        }
    }

    return res;
}

Windows output (clipboard = #):

Hello world!

String to type 1:
~!@#$%^&*()_+{}|:"<>?

String to type 2:
VaLeri+buHattI+2022 ~~ !! @@ ## $$ %% ^^ && ** (( )) __ ++ {{ }} || :: "" << >> ??

`1234567890-=[];',./ ### VaLeri+buHattI+2022 ~~ !! @@ ## $$ %% ^^ && ** (( )) __ ++ {{ }} || :: "" << >> ??

Entered string is:
`1234567890-=[];',./ ### VaLeri+buHattI+2022 ~~ !! @@ ## $$ %% ^^ && ** (( )) __ ++ {{ }} || :: "" << >> ??

Linux, Centos 8 output (clipboard = $):

Hello world!

String to type 1:
~!@#$%^&*()_+{}|:"<>?

String to type 2:
VaLeri+buHattI+2022 ~~ !! @@ ## $$ %% ^^ && ** (( )) __ ++ {{ }} || :: "" << >> ??

No protocol specified
`12345678()-=[];<./ VaLeri=buHattI=2022 `` 11 22 33 44 55 66 77 88 (( )) -- == [[ ]] \ ;; << .. //

Entered string is:
`12345678()-=[];<./ VaLeri=buHattI=2022 `` 11 22 33 44 55 66 77 88 (( )) -- == [[ ]] \ ;; << .. //

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant