Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > 10 sec poll - please reply!

Reply
Thread Tools

10 sec poll - please reply!

 
 
Dave Angel
Guest
Posts: n/a
 
      11-20-2012
On 11/20/2012 11:09 AM, John Gordon wrote:
> In <(E-Mail Removed)> Michael Herrmann <(E-Mail Removed)> writes:
>
>> What, in your view, would be the most intuitive alternative name?

> keyboard_input().
>


Well, since Python already has input() and raw_input(), it would then be
clear that keyboard_input() would take some kind of data from the
keyboard, not send it.



--

DaveA

 
Reply With Quote
 
 
 
 
Steven D'Aprano
Guest
Posts: n/a
 
      11-20-2012
On Tue, 20 Nov 2012 07:18:42 -0800, Michael Herrmann wrote:

> Thanks again for your further replies. So far, it's 4 votes for
> 'send_keys' and 1 vote for 'type'.
>
> Regarding 'send_keys': To me personally it makes sense to send keys _to_
> something. However, in our API, send_keys would not be called on an
> object or with a parameter indicating the target. It would just be
>
> send_keys(ENTER)
> send_keys("Hello World!")
> send_keys(CTRL + 'a')



"send_keys" is wrong, because you aren't sending keys. You're sending
strings, except you aren't actually sending strings either, because
"send" does not make sense without a target. You're automating the typing
of strings, including control characters.

I believe that your initial instinct for the name of this function was
correct. It automates typing, so you should call it "type" or (for those
paranoid about shadowing the built-in, "type_str".



--
Steven
 
Reply With Quote
 
 
 
 
emile
Guest
Posts: n/a
 
      11-20-2012
On 11/20/2012 04:18 AM, Michael Herrmann wrote:
> Hi,
>
> I'm developing a GUI Automation library (http://www.getautoma.com) and am having difficulty picking a name for the function that simulates key strokes. I currently have it as 'type' but that clashes with the built-in function. Example uses of 'type':
>
> type(ENTER)
>
> type("Hello World!")
>
> type(CTRL + 'a')
>
> What, in your view, would be the most intuitive alternative name?
>
> Here are my thoughts so far: I could call it 'press'


I have several tools that distinguish between press and release for
this. You may want to consider having both.

Emile

 
Reply With Quote
 
mherrmann.at@gmail.com
Guest
Posts: n/a
 
      11-20-2012
That's a very good suggestion Emile!! So I might eventually need both 'press' and 'release' (or press_key/release_key). Thanks for this!

To everyone else who has been so kind to reply thus far: What do you think of generate_keystrokes? It's a bit long but describes exactly what the function would be doing.

All of you are a great help and I really appreciate it. Thank you!

Michael

On Tuesday, 20 November 2012 17:21:38 UTC+1, emile wrote:
> On 11/20/2012 04:18 AM, Michael Herrmann wrote:
>
> > Hi,

>
> >

>
> > I'm developing a GUI Automation library (http://www.getautoma.com) and am having difficulty picking a name for the function that simulates key strokes. I currently have it as 'type' but that clashes with the built-in function. Example uses of 'type':

>
> >

>
> > type(ENTER)

>
> >

>
> > type("Hello World!")

>
> >

>
> > type(CTRL + 'a')

>
> >

>
> > What, in your view, would be the most intuitive alternative name?

>
> >

>
> > Here are my thoughts so far: I could call it 'press'

>
>
>
> I have several tools that distinguish between press and release for
>
> this. You may want to consider having both.
>
>
>
> Emile


 
Reply With Quote
 
mherrmann.at@gmail.com
Guest
Posts: n/a
 
      11-20-2012
That's a very good suggestion Emile!! So I might eventually need both 'press' and 'release' (or press_key/release_key). Thanks for this!

To everyone else who has been so kind to reply thus far: What do you think of generate_keystrokes? It's a bit long but describes exactly what the function would be doing.

All of you are a great help and I really appreciate it. Thank you!

Michael

On Tuesday, 20 November 2012 17:21:38 UTC+1, emile wrote:
> On 11/20/2012 04:18 AM, Michael Herrmann wrote:
>
> > Hi,

>
> >

>
> > I'm developing a GUI Automation library (http://www.getautoma.com) and am having difficulty picking a name for the function that simulates key strokes. I currently have it as 'type' but that clashes with the built-in function. Example uses of 'type':

>
> >

>
> > type(ENTER)

>
> >

>
> > type("Hello World!")

>
> >

>
> > type(CTRL + 'a')

>
> >

>
> > What, in your view, would be the most intuitive alternative name?

>
> >

>
> > Here are my thoughts so far: I could call it 'press'

>
>
>
> I have several tools that distinguish between press and release for
>
> this. You may want to consider having both.
>
>
>
> Emile


 
Reply With Quote
 
Mark Lawrence
Guest
Posts: n/a
 
      11-20-2012
On 20/11/2012 15:18, Michael Herrmann wrote:
> Thanks again for your further replies. So far, it's 4 votes for 'send_keys' and 1 vote for 'type'.
>
> Regarding 'send_keys': To me personally it makes sense to send keys _to_ something. However, in our API, send_keys would not be called on an object or with a parameter indicating the target. It would just be
>
> send_keys(ENTER)
> send_keys("Hello World!")
> send_keys(CTRL + 'a')


In that case I'd just call it keys, that shouldn't cause too much
confusion Though keys_pressed comes to mind as an alternative.

>
> Does that change your preference for 'send_keys'?
>
> Thanks a lot!!!
>


--
Cheers.

Mark Lawrence.

 
Reply With Quote
 
yujian4newsgroup@gmail.com
Guest
Posts: n/a
 
      11-20-2012
I write a mfc application, then I want to use the python to test this application. just as user click that button. Please tell me how to write the python application?
 
Reply With Quote
 
emile
Guest
Posts: n/a
 
      11-20-2012
On 11/20/2012 09:40 AM, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I write a mfc application, then I want to use the python to test this application. just as user click that button. Please tell me how to write the python application?


I currently use MacroScheduler (http://www.mjtnet.com/) then write
macros from within python and run them using the commands module to test.

Emile

 
Reply With Quote
 
Chris Angelico
Guest
Posts: n/a
 
      11-20-2012
On Wed, Nov 21, 2012 at 3:21 AM, Steven D'Aprano
<(E-Mail Removed)> wrote:
> On Tue, 20 Nov 2012 07:18:42 -0800, Michael Herrmann wrote:
>
>> Thanks again for your further replies. So far, it's 4 votes for
>> 'send_keys' and 1 vote for 'type'.
>>
>> Regarding 'send_keys': To me personally it makes sense to send keys _to_
>> something. However, in our API, send_keys would not be called on an
>> object or with a parameter indicating the target. It would just be
>>
>> send_keys(ENTER)
>> send_keys("Hello World!")
>> send_keys(CTRL + 'a')

>
>
> "send_keys" is wrong, because you aren't sending keys. You're sending
> strings, except you aren't actually sending strings either, because
> "send" does not make sense without a target. You're automating the typing
> of strings, including control characters.


That depends on what the function actually does. If it sends a single
command to blat a string, including control characters, to the target,
then yes, it's sending a string. But if, as my reading of the OP tells
me, the last one is "send press-Ctrl, send press-a, send release-a,
send release-Ctrl", then it's sending keys, and the name should say
so. And it's this method that the key-sender in the Yosemite project
uses (though, for hysterical raisins, its function is called "dokey" -
which I am NOT recommending).

ChrisA
 
Reply With Quote
 
Prasad, Ramit
Guest
Posts: n/a
 
      11-20-2012
Steven D'Aprano wrote:

>
> On Tue, 20 Nov 2012 07:18:42 -0800, Michael Herrmann wrote:
>

> > Thanks again for your further replies. So far, it's 4 votes for
> > 'send_keys' and 1 vote for 'type'.
> >
> > Regarding 'send_keys': To me personally it makes sense to send keys _to_
> > something. However, in our API, send_keys would not be called on an
> > object or with a parameter indicating the target. It would just be
> >
> > send_keys(ENTER)
> > send_keys("Hello World!")
> > send_keys(CTRL + 'a')

>
>
>"send_keys" is wrong, because you aren't sending keys. You're sending
> strings, except you aren't actually sending strings either, because
> "send" does not make sense without a target. You're automating the typing
> of strings, including control characters.


simulate_keypress
simulate_key(s)_down
send_kb_press
fake_typing
send_char(s)


>
> I believe that your initial instinct for the name of this function was
> correct. It automates typing, so you should call it "type" or (for those
> paranoid about shadowing thebuilt-in, "type_str".
>


I can too easily see somebody doing from module import *
OR from module import type.


~Ramit



This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Upgrade path: MCSA2000:Sec -> MCSA2003 -> MCSE2003:Sec ? The Rev [MCT] MCSE 0 12-13-2005 12:22 PM
Re: Upgrade path: MCSA2000:Sec -> MCSA2003 -> MCSE2003:Sec ? Bob Christian MCSE 1 12-13-2005 08:36 AM
Upgrade path: MCSA2000:Sec -> MCSA2003 -> MCSE2003:Sec ? =?Utf-8?B?QW1hbiBCLg==?= MCSE 0 12-13-2005 03:46 AM
No PAT from Higher Sec to Lower Sec interface Clemens Schwaighofer Cisco 0 10-20-2005 10:18 AM
Upgrade path: MCSA2000:Sec -> MCSA2003 -> MCSE2003:Sec ? =?Utf-8?B?QW1hbiBCLg==?= MCSE 4 09-07-2005 06:55 PM



Advertisments