[1.1.4]How to print Key.ENTER name?

Asked by Linda on 2019-05-13

I want to print(Key.ENTER)
then result is
ENTER

print(Key.DELETE)
the result is
DELETE

I try to Key.ENTER.__name__
There is error message: unicode object no "name" attribute

how to print key's name?

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2019-05-21
Last query:
2019-05-21
Last reply:
2019-05-16

This question was reopened

RaiMan (raimund-hocke) said : #1

I do not understand???

ENTER and DELETE are the names of the keys.

Or what do you mean by name?

Linda (kkea55534) said : #2

I def a function:
def RecordLog(KEY):
    type(KEY)
   os.system(r'echo' + type.__name__ + str(KEY) + r'>>' + Log)

But the result is not name.

For example:
Refer to :https://inventeccorp-my.sharepoint.com/:i:/g/personal/huang_linda_inventec_com/EbslPjdskOBMpgjWaCXhoX0BpWxiYuidYCemfBXDmyEXEw?e=PW76Wq

The result of print(Key.ENTER) is not ENTER but a blank.

Then try Key.DELETE: https://inventeccorp-my.sharepoint.com/:i:/g/personal/huang_linda_inventec_com/EfuTHlINS75EkrZQmfIcfMABJwgnkAKsxd1F0pkOIn_YrA?e=Nd3fEb

How to print their name to log ?

RaiMan (raimund-hocke) said : #3

The only solution I can offer:

def RecordLog(KEY):
    type(KEY)
    KEYname = Key.toJavaKeyCodeText(KEY)
    Log = "path-to-LogFile"
    os.system('echo type(%s) >>%s' % (KEYname, Log))

Key.XXX are internal non-printable binary codes

Linda (kkea55534) said : #5

Hi,RaiMan
I try with KEY_CTRL

show: toJavaKeyCodeText(): 1st arg can't be coerced to char

How to print its name?

Best RaiMan (raimund-hocke) said : #6

use Key.CTRL

Linda (kkea55534) said : #7

Thanks RaiMan, that solved my question.