Post Reply 
Python: some practice, questions and #%§'
05-15-2021, 01:04 AM
Post: #2
RE: Python: some practice, questions and #%§'
I seem to have some success with the following snippet in PPL:

Code:

#PYTHON EXPORT mktest()
from hpprime import *
from math import *

# haven't found terminal screen clear yet
print("""Perform one of the following:
1. position mouse pointer on screen and then double-touch
2. click a calculator key
3. press 'On' to exit""")
lastm,lastk=0,0
while 1:
  # gets 2nd pair of coords (2-touch)
  # move mouse ptr around screen and double touch
  m=mouse()[1]
  k=keyboard()
  if len(m)>0 and m!=lastm:
    print('2-touch y= '+str(m[1]))
  if k>0 and k!=lastk:
    print('key= '+str(int(log2(k))))
  lastm=m
  lastk=k
#end

The snippet prints the y-coord of the mouse pointer for a two-point touch, or the key code for a clicked calculator key and can be exited by pressing 'On'. Both mouse() and keyboard() don't seem to accept any parameters.

As noted in one of your previous posts, I haven't had any luck making a Python script file work (using the More>Files>New Program feature of the Editor).

Thanks for your invaluable contributions to the knowledge base. Your posted have been very helpful in trying to figure things out.

Jim
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Python: some practice, questions and #%§' - jkor - 05-15-2021 01:04 AM



User(s) browsing this thread: 1 Guest(s)