Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

How to insert "Enter" key in command

31,827 views
Skip to first unread message

Avinesh Kumar

unread,
Mar 12, 2011, 6:55:32 AM3/12/11
to xdotool-users
Hi,

I would like to know how to insert the 'Enter' Key as a command in
xdotool. I am using fedora 12

Thanks

--
Kind regards,

Avinesh

Mobile: 679 7382740
Email: avi...@avineshkumar.com

Nazri Ramliy

unread,
Mar 23, 2011, 3:01:32 AM3/23/11
to avi...@avineshkumar.com, xdotool-users
On Sat, Mar 12, 2011 at 7:55 PM, Avinesh Kumar <avi...@avineshkumar.com> wrote:
> Hi,
>
> I would like to know how to insert the 'Enter' Key as a command in
> xdotool. I am using fedora 12

This works for me:

$ xdotool key KP_Enter

nazri

Jordan Sissel

unread,
Mar 23, 2011, 3:28:47 AM3/23/11
to ayie...@gmail.com, avi...@avineshkumar.com, xdotool-users
Depending on what key you really want to use, KP_Enter or Return should work :)

-Jordan
 

nazri

--
You received this message because you are subscribed to the Google Groups "xdotool-users" group.
To post to this group, send email to xdotoo...@googlegroups.com.
To unsubscribe from this group, send email to xdotool-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xdotool-users?hl=en.


HarleyPig

unread,
Mar 31, 2011, 11:24:05 PM3/31/11
to xdotoo...@googlegroups.com, ayie...@gmail.com, avi...@avineshkumar.com
Just so I'm clear on this, if I want to type a command and then the enter key in a window I would need to do

xdotool type --window 1234 some command
xdotool key --window 1234 Return

right?

Nazri Ramliy

unread,
Mar 31, 2011, 11:38:53 PM3/31/11
to xdotoo...@googlegroups.com, HarleyPig, avi...@avineshkumar.com

Enlightenment comes to those who try.

oh wait... yoda says there is no try ...

so

just do it.

:)

HarleyPig

unread,
Apr 1, 2011, 8:56:59 AM4/1/11
to xdotoo...@googlegroups.com, HarleyPig, avi...@avineshkumar.com
I asked my question incompletely.  I have already done and verified this works.  Doing

xdotool type command
xdotool key Return

is mildly annoying when scripting a whole series of steps.  I was hoping i was missing a simpler way to do this would be available.

Jordan Sissel

unread,
Apr 1, 2011, 12:48:51 PM4/1/11
to alansy...@gmail.com, xdotoo...@googlegroups.com, avi...@avineshkumar.com
The 'type' command understands special characters like newline (\n), btw. However, it won't interpret literal "\n" (slash + n) as a newline.

This works for me:

% sleep 1; xdotool type "$(printf "hello\nworld\n")"
(the sleep is for letting me release my actual 'return' key before typing)

Or from ruby: system("xdotool", "type", "hello\nworld\n")

-Jordan

HarleyPig

unread,
Apr 1, 2011, 6:19:27 PM4/1/11
to xdotoo...@googlegroups.com, alansy...@gmail.com, avi...@avineshkumar.com
I am unable to reproduce this in either the command line or my script ( http://pastebin.com/ZyLwNF78 )

xdotool type --delay 100 --window wid 'linux text'
xdotool key --delay 100 --window wid Return

works just fine, but neither 

xdotool type --delay 100 --window wid "$(printf "linux text\n")"

nor

function xtype {
  XTYPE="$(printf "$@")"
  $DEBUG xdotool type --delay 100 --window wid "${XTYPE}"
}

xtype "linux text\n"

will work for me.

HarleyPig

unread,
Apr 1, 2011, 6:29:49 PM4/1/11
to xdotoo...@googlegroups.com, alansy...@gmail.com, avi...@avineshkumar.com
I should clarify ... by not working I mean the enter key is not pressed in the window.

Jordan Sissel

unread,
Apr 1, 2011, 9:36:18 PM4/1/11
to alansy...@gmail.com, xdotoo...@googlegroups.com, avi...@avineshkumar.com
On Fri, Apr 1, 2011 at 3:29 PM, HarleyPig <alansy...@gmail.com> wrote:
I should clarify ... by not working I mean the enter key is not pressed in the window.

Bizarro.

This works for me:
 sleep 1; ./xdotool type "$(printf "Hello\nWorld\n")" 

I do notice that it does not work if your enter/return key is currently being pressed (hence the sleep above).

Can you confirm this behavior? If so, I can work on a hack around the problem I see where if return is currently pressed, it doesn't work right.

-Jordan

Alan Young

unread,
Apr 1, 2011, 10:22:47 PM4/1/11
to Jordan Sissel, xdotoo...@googlegroups.com, avi...@avineshkumar.com
On Fri, Apr 1, 2011 at 19:36, Jordan Sissel <j...@semicomplete.com> wrote:
> On Fri, Apr 1, 2011 at 3:29 PM, HarleyPig <alansy...@gmail.com> wrote:
>> I should clarify ... by not working I mean the enter key is not pressed in
>> the window.
>
> Bizarro.
> This works for me:
>  sleep 1; ./xdotool type "$(printf "Hello\nWorld\n")"

Of course it does. :]

> I do notice that it does not work if your enter/return key is currently
> being pressed (hence the sleep above).
> Can you confirm this behavior? If so, I can work on a hack around the
> problem I see where if return is currently pressed, it doesn't work right.

It's being run from a script ( http://pastebin.com/ZyLwNF78 ), which
includes a sleep call. I've run the following:

<power off guest> ; sleep 3 ; <power on guest> ; sleep 4 ; ./vb_install

So, there is, at a minimum of 7 seconds where the keyboard is not
being touched (and closer to 30-45 seconds while the guest machines
powers down and up).
--
Alan Young

Jordan Sissel

unread,
Apr 1, 2011, 10:34:13 PM4/1/11
to Alan Young, xdotoo...@googlegroups.com, avi...@avineshkumar.com
Ok cool. I'll see if I can reproduce this and figure out why it's not working.

As an unfortunate data point, a few months back, I had scripted (with xdotool) a screencast demo of another of my project, and it types newlines just fine :(

In the mean time, if you find more data points about it not working, please let me know.

-Jordan

Alan Young

unread,
Apr 1, 2011, 11:03:53 PM4/1/11
to Jordan Sissel, xdotoo...@googlegroups.com, avi...@avineshkumar.com
On Fri, Apr 1, 2011 at 20:34, Jordan Sissel <j...@semicomplete.com> wrote:
> As an unfortunate data point, a few months back, I had scripted (with
> xdotool) a screencast demo of another of my project, and it types newlines
> just fine :(
> In the mean time, if you find more data points about it not working, please
> let me know.

I wonder if it's specific to virtualbox ... I haven't tried to
actually just run it in a terminal window ... something to try later.
--
Alan Young

Reply all
Reply to author
Forward
0 new messages