Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'handler': 0.04; 'context': 0.05; 'much!': 0.05; 'mouse': 0.07; 'strings.': 0.07; 'url:msdn': 0.07; 'valueerror:': 0.07; 'works.': 0.07; 'api': 0.09; 'ambiguity': 0.09; 'closest': 0.09; 'friday,': 0.09; 'handler,': 0.09; 'pressing': 0.09; 'to:addr:comp.lang.python': 0.09; 'valueerror': 0.09; 'cc:addr:python-list': 0.10; 'gui': 0.11; 'background.': 0.13; 'library': 0.15; '"key"': 0.16; "(it's": 0.16; 'amiga': 0.16; 'chained': 0.16; 'character:': 0.16; 'clashes': 0.16; 'exercise:': 0.16; 'how,': 0.16; 'movements,': 0.16; 'perfect.': 0.16; 'pressed': 0.16; 'url:visualstudio': 0.16; 'world!")': 0.16; 'string': 0.17; 'wrote:': 0.17; 'certainly': 0.17; 'instance': 0.17; 'pointed': 0.17; "shouldn't": 0.17; 'thu,': 0.17; '>>>': 0.18; 'input': 0.18; 'written': 0.20; 'meant': 0.21; 'releasing': 0.22; 'url:com)': 0.22; 'cc:2**0': 0.23; 'example': 0.23; 'cheers': 0.24; 'raise': 0.24; 'cc:no real name:2**0': 0.24; 'idea': 0.24; 'allows': 0.25; 'least': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'thanks!': 0.26; 'raw': 0.27; 'wonder': 0.27; 'subject:please': 0.27; 'thoughts': 0.27; "doesn't": 0.28; 'developing': 0.28; 'about.': 0.29; 'far.': 0.29; 'name?': 0.29; 'probably': 0.29; "i'm": 0.29; 'maybe': 0.29; 'function': 0.30; 'button': 0.30; 'point': 0.31; 'anybody': 0.32; 'could': 0.32; 'accessible': 0.33; "aren't": 0.33; 'automation': 0.33; 'controlling': 0.33; 'function.': 0.33; 'picking': 0.33; 'url:home': 0.33; 'hi,': 0.33; 'another': 0.33; 'that,': 0.34; 'agree': 0.34; 'received:google.com': 0.34; 'done': 0.34; 'thanks': 0.34; 'clear': 0.35; 'built-in': 0.35; 'nov': 0.35; 'so,': 0.35; 'doing': 0.35; 'received:209.85': 0.35; 'michael': 0.36; 'tool': 0.36; 'but': 0.36; 'wanted': 0.36; 'url:library': 0.36; 'method': 0.36; 'should': 0.36; 'thank': 0.36; 'uses': 0.37; 'being': 0.37; 'passed': 0.37; 'rather': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'some': 0.38; 'things': 0.38; 'there,': 0.38; 'several': 0.39; 'release': 0.39; 'easily': 0.39; 'called': 0.39; 'url:microsoft': 0.39; 'where': 0.40; 'skip:" 10': 0.40; 'think': 0.40; 'your': 0.60; 'url:aspx': 0.60; 'most': 0.61; 'letters': 0.62; 'between': 0.63; 'more': 0.63; 'here': 0.65; 'our': 0.65; '20,': 0.65; 'difficulty': 0.65; 'sound': 0.65; 'url:en-us': 0.65; 'wanting': 0.65; 'reply': 0.66; 'url:%1': 0.68; 'press': 0.71; 'click': 0.76; 'around,': 0.84; 'decades,': 0.84; 'distinguish': 0.84; 'injecting': 0.84; 'keystrokes': 0.84; 'mistaken': 0.84; 'dennis': 0.91; 'justice': 0.93 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=path:newsgroups:date:in-reply-to:complaints-to:injection-info :nntp-posting-host:references:user-agent:x-google-web-client :x-google-ip:mime-version:message-id:subject:from:to:cc:content-type :content-transfer-encoding:x-gm-message-state; bh=sKR/hmeHGXZiEd+ObvgoDDhEg2XORqwuVL2SChR1TAo=; b=ONTg2dBJcqy7htD01LDZl1HJwmuWFxKAym1I4YOfR71dXkT1CitxpKXJUVWe3cvuPs VShjihmFDIxNwa7rllentd+54ODkrRPEMO7msSIvwK8PTn85KSjO6mu378Xykx3ROTY2 DEzbsuaEetkUaaEzzRpKYM6y9UG7p7L+OjzJ6y/4ZFrrhnQJo4p5LC+9pgTw2o6sfFSl hjPemIW1BMiF6UdfLzQZJB36HVzQqv41O5dRLzrgI6ddB9NivheMl4tm7/8bqIzQL+mV 9M4cALTLCJlw1/KxmmacoDjjmk2SDUToDRp5WB5EiU0m2lnaX8VkIYOCPRMvrUe2Lffn qNZg== Newsgroups: comp.lang.python Date: Sat, 24 Nov 2012 13:07:26 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=80.109.122.186; posting-account=oknH1QoAAABqzbD_5ziFTvLQsqNk2LbU References: <3d71f175-164e-494c-a521-2eaa5679b524@googlegroups.com> <818c157c-1395-441d-ad99-955a31b0d523@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 80.109.122.186 MIME-Version: 1.0 Subject: Re: 10 sec poll - please reply! From: Michael Herrmann To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQmYYzwMcKhre6WH+tkns5lq8gRrdSJXITJ1b0qEt9TlN0gDFcIcA5c/r4V9o3QSXMxZtU9v Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 188 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1353791249 news.xs4all.nl 6930 [2001:888:2000:d::a6]:42449 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33890 Thanks for your reply Dennis, the commands sounding like they should be commands to a user is the whole p= oint of the exercise: In doing so, we hope to make the API accessible also = to users from a less technical background. You are perfectly right that sys= tem events are being generated and passed around, however that is not what = these users care about. Frankly, also I coming from a very technical backgr= ound don't care which events are generated and how, as long as it works.=20 I agree that "key_down"/"key_up" has a nice symmetry to it. Maybe a solutio= n could also be to use a context manager: with key_down(SHIFT): # some action... Cheers On Friday, November 23, 2012 11:11:34 PM UTC+1, Dennis Lee Bieber wrote: > On Thu, 22 Nov 2012 10:00:54 -0800 (PST), Michael Herrmann >=20 > declaimed the following in >=20 > gmane.comp.python.general: >=20 >=20 >=20 > > These names aren't perfect. As Emile rightly pointed out, several tools= distinguish between 'press' and 'release' and a user might wonder how to r= elease a key that was pressed using 'press'. That's an ambiguity that is ce= rtainly there, however we hope that once the user has at least seen >=20 > > press(ENTER) >=20 > > it is clear what is meant. Distinguishing between pressing and releasin= g could we think easily be done with, say >=20 > > hold_down(SHIFT) >=20 > > ... >=20 > > release(SHIFT) >=20 > > Another ambiguity of 'press' that I pointed out in my original mail is = that it could also be understood as "pressing a button". The current idea i= s to raise a ValueError if the user supplies a string that is longer than o= ne character: >=20 > > >>> press("OK") >=20 > > ValueError: 'press' generates keystrokes and can only press single let= ters at a time. Did you maybe mean click("OK") or press('O', 'K')? >=20 > >=20 >=20 >=20 >=20 > "press", "hold_down", "release" just sound so much like they should >=20 > be commands to a /user/ not to a means of programmatically controlling >=20 > an interface. A "user" presses a button -- but a program is just >=20 > injecting the "event" of a button press into the input processing stream >=20 > (it's been decades, but I still think in Amiga terms -- where all input >=20 > events routed through one input handler and chained to the programs >=20 > wanting to work with raw events... This meant that, but injecting the >=20 > event codes before the input handler, a program could make another >=20 > program [including the OS] think one had ejected/inserted floppies, >=20 > mouse movements, keystrokes) >=20 >=20 >=20 > "hold_down" and "release" would seem more memorable, and symmetric, >=20 > if named "key_down" and "key_up"; and if "press" is limited to single >=20 > codes -- "key" [or "keystroke"] >=20 >=20 >=20 > The closest M$ .Net method is called SendKeys() and works with >=20 > strings. >=20 > http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.= uitesting.keyboard.sendkeys%28v=3Dvs.100%29.aspx >=20 >=20 >=20 >=20 >=20 >=20 >=20 >=20 >=20 >=20 >=20 > > What do you think of this solution? I hope anybody read this far. I pro= bably shouldn't have written that much but wanted to do justice to your inp= uts. >=20 > >=20 >=20 > > Thanks! >=20 > >=20 >=20 > > Michael >=20 > >=20 >=20 > > On Tuesday, November 20, 2012 1:18:38 PM UTC+1, Michael Herrmann wrote: >=20 > > > Hi,=20 >=20 > > >=20 >=20 > > >=20 >=20 > > >=20 >=20 > > > I'm developing a GUI Automation library (http://www.getautoma.com) an= d am having difficulty picking a name for the function that simulates key s= trokes. I currently have it as 'type' but that clashes with the built-in fu= nction. Example uses of 'type':=20 >=20 > > >=20 >=20 > > >=20 >=20 > > >=20 >=20 > > > type(ENTER) >=20 > > >=20 >=20 > > >=20 >=20 > > >=20 >=20 > > > type("Hello World!") >=20 > > >=20 >=20 > > >=20 >=20 > > >=20 >=20 > > > type(CTRL + 'a') >=20 > > >=20 >=20 > > >=20 >=20 > > >=20 >=20 > > > What, in your view, would be the most intuitive alternative name? >=20 > > >=20 >=20 > > >=20 >=20 > > >=20 >=20 > > > Here are my thoughts so far: I could call it 'press' but then our GUI= automation tool also allows you to click things and then "press" might be = mistaken for "pressing a button". A less ambiguous alternative is "type_key= s" but that is rather long and doesn't read as well, for instance in type_k= eys(ENTER). >=20 > > >=20 >=20 > > >=20 >=20 > > >=20 >=20 > > > Thank you very much! >=20 > --=20 >=20 > Wulfraed Dennis Lee Bieber AF6VN >=20 > HTTP://wlfraed.home.netcom.com/