ubuntukeysimulationxdotool

What would be the reason that Ubuntu fails to execute the xdotool key period command?


running a script that uses the "xdotool", "key comma" and "xdotool", "key period". Yet it seems to skip the period commands entirely or perhaps can't interpret them?

Using OS Ubuntu 22.04.4 LTS

static void processBaseImage(string windowName, string directoryPath)
        {
            string baseImage = processWindow(windowName, directoryPath, "base");
            if (baseImage != null)
            {
                Thread.Sleep(1000);
                Process.Start("xdotool", "key comma");
                string zoomedOutImage = processWindow(windowName, directoryPath, "zoomed_out");
                if (zoomedOutImage != null)
                {
                    // add a few extra zoom in keystrokes to ensure image has been adjusted as by human eye its difficult to see
                    // however the image compare function does tell us that the images are different
                    Console.WriteLine("Zooming in functions to begin");
                    Thread.Sleep(1000);
                    Process.Start("xdotool", "key period");
                    Process.Start("xdotool", "key period");
                    Console.WriteLine("Zooming in functions completed");
                    string zoomedInImage = processWindow(windowName, directoryPath, "zoomed_in");
                    compareImagesForFocus(baseImage, zoomedOutImage, zoomedInImage, directoryPath);
                }
            }
        }

The comma key emulation works without issue, but the period emulation just doesn't happen. from the documents "key period" is the proper way to invoke the "." key, and if changed to "." instead of "period" we get and invalid sequence error. Im able to get both console lines stating the zooming in function to begin and completed, so it really feels like we're just skipping right over the period commands, would anyone have any ideas as to why? or perhaps an alternative?


Solution

  • Have you tried checking if you have xdotool installed? Also try to reproduce this in another C# project, only trying to run xdotool. Check if you have imported System.Diagnostics .

    Try using the Process class instead (I wouldn't recommend this one for your use case as it works better on windows, but it might work):

    Process xdotool = new Process();
    
    xdotool.StartInfo.FileName = "xdotool";
    xdotool.StartInfo.Arguments = "key comma";
    xdotool.Start();
    xdotool.WaitForExit(); // wait for finish