Error when automating type option via xdotool Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Error when automating type option via xdotool without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I want to open Chromium browser and then open a couple of web pages, let’s say “”, and “”. My code for the same is below.

#website 1
xdotool type
xdotool key --delay 2000 'Return'
xdotool key 'ctrl+Tab'

#website 2
xdotool type
xdotool key --delay 2000 'Return'

The problem:

1) This piece of code only works when I already have a Chromium browser open. Then only, it opens another Chromium browser (as per the code) and performs everything perfectly.

2) If I don’t have a browser already open, then this script just opens the browser and does nothing.

Where am I going wrong? Why do I need to have another browser open for the code to work?


Chromium open the tabs on its own, without needing xdotool :

chromium-browser &

Will open a new chromium window (if none was opened before) with 2 tabs

then you can switch between the tabs with xdotool with

xdotool search --onlyvisible --class "chromium" windowfocus key 'ctrl+Tab'

if you want to repeat every 5 seconds :

while true ; do sleep 5 ; xdotool key 'ctrl+Tab' ; done
We are here to answer your question about Error when automating type option via xdotool - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji