Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33888
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2012-11-24 12:56 -0800 |
| References | <3d71f175-164e-494c-a521-2eaa5679b524@googlegroups.com> <818c157c-1395-441d-ad99-955a31b0d523@googlegroups.com> <780646bd-4caf-4080-b549-cf30a6df0fdf@googlegroups.com> <50aff8eb$0$29975$c3e8da3$5496439d@news.astraweb.com> |
| Message-ID | <12f7d5d3-58af-4c5e-a6ee-e064e198c4bd@googlegroups.com> (permalink) |
| Subject | Re: 10 sec poll - please reply! |
| From | Michael Herrmann <michael.herrmann@getautoma.com> |
Hi Steven,
press('s') is allowed. So is press('S') - it presses shift for you and is thus equivalent to press(SHIFT + 's'). You can write press('f', 's'). You cannot write press('fs') because that's what enter(...) is for. If you try - or, as I would deem more likely, happen do to it by mistake - you get the following warning:
>>> press('fs')
ValueError: 'press' generates single keystrokes and is not intended to be used for typing in long plain-text strings. Did you maybe mean one of the following?
* enter("fs")
* click("fs")
* press('f', 's')
I'm not aware of CTRL + i having a connection with TAB. You cannot use it to get a tab. We haven't decided on what to do when you press('\t'). If you want three tabs, you can write
press(TAB, TAB, TAB)
If you want a tab, a letter and a newline, you can do
enter("""\tA
\tB
\tC
""")
The reasoning is that you are entering plain text, that is a string that you would like to appear in the window you are typing into in the same way as you are supplying it to `enter`.
If you want to type "Hello World!" without entering it, you call
enter("Hello World!")
Yes, I did write "call *enter* to do X *without entering*". You are hinting at a valid ambiguity with `enter` that Chris already pointed out. I don't think it's worse than the ambiguity of
>>> type("Hello World!")
<type 'str'>
We would need a new function for holding down keys to release them later. You are again pointing out an imho valid ambiguity. However, you were just happily using `press` with the understanding that it presses and releases keys, so I hope this one isn't too bad.
As I said, I opened a new thread solely for overriding `type` in the context of a GUI automation library: https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.python/GjZ2hAS1Wyk. So far, 4/4 people there advised against it. If only Python hadn't defined `type`...
Michael
On Friday, November 23, 2012 11:30:04 PM UTC+1, Steven D'Aprano wrote:
> On Fri, 23 Nov 2012 05:42:22 -0800, Michael Herrmann wrote:
>
>
>
> > Dear all,
>
> >
>
> > the emails are getting kind of long so to ask you briefly: What do you
>
> > think of splitting `type` into two functions `press` and `enter`?
>
>
>
> This invites confusion as to the rules of when you can call `press` and
>
> when you can call `enter`. Especially since you haven't explained the
>
> rules, just given a bunch of non-exhaustive examples and invited people
>
> to extrapolate what the rules are.
>
>
>
> (By the way, they aren't use-cases, they're examples.)
>
>
>
>
>
> > Their use cases are:
>
> > press(CTRL + 'a')
>
> > press(ENTER)
>
> > press(ALT + 'f', 's')
>
> > enter("Hello World!")
>
> > enter("test.txt", into="File name")
>
>
>
>
>
> Is `press('s')` allowed?
>
>
>
> What about `press('S')`, or do I have to write `press(SHIFT + 's')`?
>
>
>
> If I can write `press(ALT + 'f', 's')`, can I write `press('f', 's')`? If
>
> not, why not?
>
>
>
> Can I write `press('fs')` as a simpler version of `press('f', 's')`? If
>
> not, why not?
>
>
>
> Can I write `press(CTRL + 'i')` to get a tab? How about `press('\t')`?
>
>
>
> If I want three tabs, can I write `press('\t\t\t')`, or do I have to write
>
>
>
> press(CTRL + 'i')
>
> press(CTRL + 'i')
>
> press(CTRL + 'i')
>
>
>
> If I want a tab, a letter, and a newline, repeated three times, can I do
>
> this?
>
>
>
> press("""\tA
>
> \tB
>
> \tC
>
> """)
>
>
>
> Or do I have to do this?
>
>
>
> press(CTRL + 'i')
>
> enter('A')
>
> press(CTRL + 'i')
>
> enter('B')
>
> press(CTRL + 'i')
>
> enter('C')
>
>
>
> Speaking of enter, how do I type "Hello World!" without entering it? If I
>
> want to type "Hello World!" without ENTER, do I have to do this?
>
>
>
> press('H')
>
> press('e')
>
> press('l')
>
> press('l')
>
> ... you get the picture
>
>
>
>
>
> With a function named "press", I would expect to be able to say:
>
>
>
> press('a')
>
> time.sleep(5)
>
> release('a')
>
>
>
> How do I do something like that?
>
>
>
>
>
>
>
> --
>
> Steven
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
10 sec poll - please reply! Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-20 04:18 -0800
Re: 10 sec poll - please reply! Chris Angelico <rosuav@gmail.com> - 2012-11-20 23:23 +1100
Re: 10 sec poll - please reply! Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-20 13:09 +0000
Re: 10 sec poll - please reply! Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-20 05:17 -0800
Re: 10 sec poll - please reply! Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-20 05:20 -0800
Re: 10 sec poll - please reply! Dave Angel <davea@dejaviewphoto.com> - 2012-11-20 08:39 -0500
Re: 10 sec poll - please reply! Neil Cerutti <neilc@norwich.edu> - 2012-11-20 14:39 +0000
Re: 10 sec poll - please reply! Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-20 07:18 -0800
Re: 10 sec poll - please reply! MRAB <python@mrabarnett.plus.com> - 2012-11-20 15:59 +0000
Re: 10 sec poll - please reply! Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-20 16:21 +0000
Re: 10 sec poll - please reply! Chris Angelico <rosuav@gmail.com> - 2012-11-21 07:57 +1100
RE: 10 sec poll - please reply! "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-20 21:08 +0000
Re: 10 sec poll - please reply! Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-21 01:20 +0000
Re: 10 sec poll - please reply! Tim Chase <python.list@tim.thechases.com> - 2012-11-20 19:39 -0600
Re: 10 sec poll - please reply! Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-11-20 16:31 +0000
Re: 10 sec poll - please reply! Alan Meyer <ameyer2@yahoo.com> - 2012-11-20 18:46 -0500
Re: Re: 10 sec poll - please reply! Evan Driscoll <driscoll@cs.wisc.edu> - 2012-11-20 19:51 -0600
Re: 10 sec poll - please reply! Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-11-20 19:01 -0500
Re: 10 sec poll - please reply! Alan Bawden <alan@scooby-doo.csail.mit.edu> - 2012-11-20 21:15 -0500
Re: 10 sec poll - please reply! John Gordon <gordon@panix.com> - 2012-11-20 16:09 +0000
Re: 10 sec poll - please reply! Dave Angel <d@davea.name> - 2012-11-20 11:19 -0500
Re: 10 sec poll - please reply! emile <emile@fenx.com> - 2012-11-20 08:21 -0800
Re: 10 sec poll - please reply! mherrmann.at@gmail.com - 2012-11-20 08:29 -0800
How to use the python to do the unit test "yujian4newsgroup@gmail.com" <yujian4newsgroup@gmail.com> - 2012-11-21 01:40 +0800
Re: How to use the python to do the unit test emile <emile@fenx.com> - 2012-11-20 09:51 -0800
Re: 10 sec poll - please reply! xDog Walker <thudfoo@gmail.com> - 2012-11-20 13:33 -0800
Re: How to use the python to do the unit test Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-11-20 22:02 +0000
Re: 10 sec poll - please reply! mherrmann.at@gmail.com - 2012-11-20 08:29 -0800
Re: 10 sec poll - please reply! Tim Chase <python.list@tim.thechases.com> - 2012-11-20 18:00 -0600
Re: 10 sec poll - please reply! Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-21 01:17 +0000
Re: 10 sec poll - please reply! Tim Chase <python.list@tim.thechases.com> - 2012-11-20 19:30 -0600
Re: 10 sec poll - please reply! Hans Mulder <hansmu@xs4all.nl> - 2012-11-21 13:33 +0100
Re: 10 sec poll - please reply! rh <richard_hubbe11@lavabit.com> - 2012-11-20 21:25 -0800
Re: 10 sec poll - please reply! Chris Angelico <rosuav@gmail.com> - 2012-11-21 17:35 +1100
Re: 10 sec poll - please reply! Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-21 07:01 +0000
Re: 10 sec poll - please reply! Andrew Cooper <andrew@nospam.example.com> - 2012-11-21 22:24 +0000
Re: 10 sec poll - please reply! markus.moldaschl@gmail.com - 2012-11-21 01:29 -0800
Re: 10 sec poll - please reply! Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-21 09:19 -0800
Re: 10 sec poll - please reply! Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-22 10:00 -0800
Re: 10 sec poll - please reply! Chris Angelico <rosuav@gmail.com> - 2012-11-23 06:08 +1100
Re: 10 sec poll - please reply! Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-22 13:45 -0800
Re: 10 sec poll - please reply! Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-22 13:45 -0800
Re: 10 sec poll - please reply! Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-23 05:41 +0000
Re: 10 sec poll - please reply! Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-23 01:08 -0800
Re: 10 sec poll - please reply! Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-23 08:15 -0800
Re: 10 sec poll - please reply! Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-23 05:42 -0800
Re: 10 sec poll - please reply! Kwpolska <kwpolska@gmail.com> - 2012-11-23 17:42 +0100
Re: 10 sec poll - please reply! Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-23 09:29 -0800
Re: 10 sec poll - please reply! Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-23 09:29 -0800
Re: 10 sec poll - please reply! Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-23 22:30 +0000
Re: 10 sec poll - please reply! Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-24 12:56 -0800
Re: 10 sec poll - please reply! Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-11-24 18:22 -0500
Re: 10 sec poll - please reply! Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-25 05:41 -0800
Re: 10 sec poll - please reply! Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-11-23 17:10 -0500
Re: 10 sec poll - please reply! Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-24 13:07 -0800
Re: 10 sec poll - please reply! Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-25 03:56 +0000
Re: 10 sec poll - please reply! Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-25 05:45 -0800
Re: 10 sec poll - please reply! Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-24 13:07 -0800
Re: 10 sec poll - please reply! Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-24 13:59 -0800
Re: 10 sec poll - please reply! ALeX inSide <alex.b.inside@gmail.com> - 2012-11-25 04:13 -0800
Re: 10 sec poll - please reply! Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-29 03:45 -0800
csiph-web