Score:0

Xdotool not displaying any results

sb flag

I am a beginner to Linux and really having fun using it so far, but it seems that there is a problem I cannot solve, or at least don't quite understand -- The xdotool from X11 Project doesn't work on Ubuntu under either my VirtualBox installation or my Windows WSL installation.

I have done everything I can but still no luck.

  • My VirtualBox Ubuntu Release is 22.10, and yes I am using Xorg not Wayland.
  • In WSL, I downloaded the Xming X Server for Windows from sourceforge.com.

Here is what I did in both of them:

sudo apt update 
sudo apt  install xdotool
xdotool type "hello"

Nothing happens ... no errors, nothing.

Both WSL and VirtualBox Ubuntu's have the same exact response -- Nothing.

Example

Score:1
vn flag

I can't speak to what's happening in your VirtualBox installation (but I suspect it's something similar). The issue with WSL, at least, is that you don't appear to have an X application running in which to target the output of Xdotool. If you do, you don't mention it, at least.

It's an easy mistake to make -- I did it myself just a few days ago when trying something out.

Just running the X server doesn't give it a target application. You would need to be running the command above in an X terminal application, such as Xterm in order to see the results.

The terminal in which Ubuntu is running under WSL is not, of course, an X application; it's a Windows application.

Also note that you shouldn't even need Xming any more for this to work. All recent releases of WSL support GUI applications directly. See this answer for more information. It's doubtful that the KB patch is even needed any longer, as it should be integrated into the mainline monthly servicing releases at this point.

With that installed, remove any changes to the DISPLAY variable that you put in place for Xming. The stock WSL should manage DISPLAY correctly.

Then:

sudo apt install xterm

From WSL, run xterm. And inside that Xterm terminal, run your:

xdotool type "hello"

You should see the Hello entered at the next prompt-line in Xterm.

Note that, according to this answer many applications do not accept "sent" keystrokes unless they are already the foreground application. This is for security reasons.

hr flag
I'm puzzled about the OP's lack of success in VirtualBox as well - I wonder if it's terminal dependent? It works for me in a Lubuntu 22.04 VM, with both qterminal and xterm.
fahad almarri  avatar
sb flag
I Think i broke my **Display** variable. This error keeps showing (xterm: Xt error: Can't open display: xterm: DISPLAY is not set)
fahad almarri  avatar
sb flag
Regarding @steeldriver. Actually xdotool worked on my VB. It appears that i had to logout of ubuntu then choose XORG before logging back in to my account. XD
fahad almarri  avatar
sb flag
God Bless @NotTheDr01ds It works!! Regarding my Error, IT that "**DISPLAY is not Set**", it appears there is a file, located in my root dir called .wslconfig that contains the following: [wsl2] guiApplications=false . i just changed it from **false** to **true**
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.