Simulate keypress in a script

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 3461
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Simulate keypress in a script

Post by richmond62 » Sun Dec 23, 2018 7:10 pm

if one does this in a cardScript:

Code: Select all

on rawKeyUp PP
put PP
end rawKeyUp
one ends up with 65363 in the messageBox

this is the code the operating system uses for the right arrow key

However, it is also a Unicode glyph address (0xFF53): http://www.unicode.org/charts/PDF/UFF00.pdf

and this is why an 's' gets dumped in a field when one does this sort of thing:

Code: Select all

type numToCodePoint(65363)
this

Code: Select all

type "arrowKey right"
inserts "arrowKey right" at an insertion point

and

Code: Select all

send "arrowKey right"
does nothing
Last edited by richmond62 on Sun Dec 23, 2018 8:38 pm, edited 1 time in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6116
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Simulate keypress in a script

Post by dunbarx » Sun Dec 23, 2018 7:13 pm

I think Richard or Klaus should move this thread to "Talking Livecode". It is not a feature request, per se, though I bet the OP wishes it were.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 3461
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Simulate keypress in a script

Post by richmond62 » Sun Dec 23, 2018 7:16 pm

At the very start of the Unicode "thang" there are lots of what are called 'control characters'
(which I cannot understand). I suppose one of the ways to send and/or type
what an arrowKey right does is to find out which control character
in the Unicode set does this . . .
-
altKey state.png
altKey state.png (7.01 KiB) Viewed 770 times
-
my pseudoCode would do this:

put the altKey into right

and then something like this:

https://www.alt-codes.net/arrow_alt_codes.php

What I mean, is somehow set the stack to see the altKey as Down.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 3461
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Simulate keypress in a script

Post by richmond62 » Sun Dec 23, 2018 8:29 pm

What, perhaps, should be pointed out, is that as LiveCode is (at least partly) cooked in C++
there are ways to fake arrow keys in C++

VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT

which, presumably, could be rolled into LiveCode without undue fuss.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 3461
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Simulate keypress in a script

Post by richmond62 » Sun Dec 23, 2018 9:11 pm

One of the snags here is that, while in javaScript and so on one can play around with
the keycode of a key on a keyboard, and find out that the keycode for the left arrowKey is 37, and the right arrowKey is 39, and then make use of that information, I for one cannot work out how one might do that in LiveCode.
-
keycodes.png
keycodes.png (16.17 KiB) Viewed 751 times
-
LiveCode, frustratingly, mentions this:
-
keycode.png
-
but then lets one down with a damp squib.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 3461
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Simulate keypress in a script

Post by richmond62 » Sun Dec 23, 2018 9:37 pm

Part of this discussion is
-
old hat.jpg
old hat.jpg (4.09 KiB) Viewed 746 times
-
old hat
-
https://www.mail-archive.com/use-liveco ... 28081.html

Post Reply

Return to “Feature Requests”