Simulate enter key

I have a popup window that appears on every boot up.

I would like to have it dismissed automatically each time instead of having to hit the enter key.

I thought I could write a script that would execute on startup.

I tried this

xdotool key return

andy@7_~/Downloads$ xdotool key [return]
Error: Invalid key sequence '[return]'
Failure converting key sequence '[return]' to keycodes
Error: Invalid key sequence '[return]'
Failure converting key sequence '[return]' to keycodes

Isn't that error message self-explaining?
Try - from the man page - return or ctrl+m or ctrl+j ; no square brackets.

And - wouldn't it be better to analyse the boot process and find out how NOT to pop up that window?

andy@7_~/Downloads$ xdotool key -return
key: unrecognized option '-return'

I already have. It is a known bug.

The window id changes with each boot even though it is for the same popup window.

#!/bin/bash
# xdotool selectwindow This determines the window id or 2nd method
# xdotool search --name "Error"
xdotool key --window 16777491 alt+F4

I need help with passing the value of xdotool search --name "Error" to xdotool key --window 16777491 alt+F4 statement.

--- Post updated at 06:35 AM ---

This works if run from a cli window but not when run as a Startup Application.

Using UbuntuMate 18.04.

#!/bin/bash
#
#  Automatically close that popup windows that occurs with every boot up 
#
# xdotool selectwindow This determines the window id or 2nd method
# xdotool search --name "Error"
id=$(xdotool search --name "Error")

xdotool key --window $id alt+F4

I don't know the tool, but would

xdotool --name "Error" key alt+F4

work? If not, maybe

xdotool key --window $(xdotool search --name "Error") alt+F4

?

My script above does work, but only from a terminal which is not what I need.

I need it to run on each bootup.

In what way does it not work on boot? What exactly did you do? What ran the code? Was everything in PATH? etc.

I have decided to try another method.

I will make a separate post.