Polling/probing the keyboard?

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Polling/probing the keyboard?

Richmond Mathewson-2
I have a North American English keyboard attached to my machine, but Dr
Savov
has a Russian one attached to his machine. I don't know what sort of
keyboard
and/or layout Dr Savov uses; but I would like my Livecode standalone to
find out.

Now I can use a script like this:

send "mouseUp" to btn "BTTN"

but I cannot do this:

send "keyDown" to key 112

where 112 is the rawKeyDown value of that key on my keyboard.

Does anybody know whether this sort of thing can be achieved in Livecode?


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Polling/probing the keyboard?

William Humphrey
When you set up a new keyboard on an apple computer it tells you to hit the left most key next to space bar and then right most key. Then based on that information it knows what kind of keyboard you have.

Brevity and errors in this email probably the result of being sent by a mobile device.

> On Dec 20, 2013, at 10:49 AM, Richmond <[hidden email]> wrote:
>
> I have a North American English keyboard attached to my machine, but Dr Savov
> has a Russian one attached to his machine. I don't know what sort of keyboard
> and/or layout Dr Savov uses; but I would like my Livecode standalone to find out.
>
> Now I can use a script like this:
>
> send "mouseUp" to btn "BTTN"
>
> but I cannot do this:
>
> send "keyDown" to key 112
>
> where 112 is the rawKeyDown value of that key on my keyboard.
>
> Does anybody know whether this sort of thing can be achieved in Livecode?
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Polling/probing the keyboard?

Simon
In reply to this post by Richmond Mathewson-2
Hi Richond,
I just did a vb script for send keys today;

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate "Untitled 1 *"
Wscript.Sleep 1000 'wait 1 seconds
WshShell.SendKeys "abcdefghijklmnopqrstuvwxyz"
WshShell.SendKeys "{ENTER}"
WScript.Quit

With that and a running exe (title bar "Untitled 1 *) the keys get caught by the stack.
Not sure if that helps you but I figure you might then be able to map the keys.

Simon
Reply | Threaded
Open this post in threaded view
|

Re: Polling/probing the keyboard?

Richmond Mathewson-2
On 21/12/13 09:39, As_Simon wrote:

> Hi Richond,
> I just did a vb script for send keys today;
>
> Set WshShell = WScript.CreateObject("WScript.Shell")
> WshShell.AppActivate "Untitled 1 *"
> Wscript.Sleep 1000 'wait 1 seconds
> WshShell.SendKeys "abcdefghijklmnopqrstuvwxyz"
> WshShell.SendKeys "{ENTER}"
> WScript.Quit
>
> With that and a running exe (title bar "Untitled 1 *) the keys get caught by
> the stack.
> Not sure if that helps you but I figure you might then be able to map the
> keys.
>
> Simon
>
>
That's jolly clever.

However, at the risk of being a damp squib, I am wondering if there is a
way to do this inwith Livecode for 2 sound reasons:

1. vb script would tie one to Windows; as pretty well any script would
tie one to a specific operating system.

2. Livecode's greatest strength is that one develop something on one
platform and then deploy it all over the place.

Richmond.

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Polling/probing the keyboard?

william humphrey-2
If this was possible to do on Mac OS why does Apple have you
physically hit the keys on the keyboard when you add a new keyboard
(by plugging it in USB or over Bluetooth). If the keyboard could be
told to send that data it would be much easier.

On Sat, Dec 21, 2013 at 5:11 AM, Richmond <[hidden email]> wrote:

> On 21/12/13 09:39, As_Simon wrote:
>>
>> Hi Richond,
>> I just did a vb script for send keys today;
>>
>> Set WshShell = WScript.CreateObject("WScript.Shell")
>> WshShell.AppActivate "Untitled 1 *"
>> Wscript.Sleep 1000 'wait 1 seconds
>> WshShell.SendKeys "abcdefghijklmnopqrstuvwxyz"
>> WshShell.SendKeys "{ENTER}"
>> WScript.Quit
>>
>> With that and a running exe (title bar "Untitled 1 *) the keys get caught
>> by
>> the stack.
>> Not sure if that helps you but I figure you might then be able to map the
>> keys.
>>
>> Simon
>>
>>
> That's jolly clever.
>
> However, at the risk of being a damp squib, I am wondering if there is a way
> to do this inwith Livecode for 2 sound reasons:
>
> 1. vb script would tie one to Windows; as pretty well any script would tie
> one to a specific operating system.
>
> 2. Livecode's greatest strength is that one develop something on one
> platform and then deploy it all over the place.
>
> Richmond.
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



--
http://www.bluewatermaritime.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Polling/probing the keyboard?

Richmond Mathewson-2
On 22/12/13 20:59, william humphrey wrote:
> If this was possible to do on Mac OS why does Apple have you
> physically hit the keys on the keyboard when you add a new keyboard
> (by plugging it in USB or over Bluetooth). If the keyboard could be
> told to send that data it would be much easier.

I don't know what you are talking about; I happily swap keyboards around
amongst my various machines
(which include 2 PPC Macs) with no observable problems, nor what you
describe.

Richmond.

>
> On Sat, Dec 21, 2013 at 5:11 AM, Richmond <[hidden email]> wrote:
>> On 21/12/13 09:39, As_Simon wrote:
>>> Hi Richond,
>>> I just did a vb script for send keys today;
>>>
>>> Set WshShell = WScript.CreateObject("WScript.Shell")
>>> WshShell.AppActivate "Untitled 1 *"
>>> Wscript.Sleep 1000 'wait 1 seconds
>>> WshShell.SendKeys "abcdefghijklmnopqrstuvwxyz"
>>> WshShell.SendKeys "{ENTER}"
>>> WScript.Quit
>>>
>>> With that and a running exe (title bar "Untitled 1 *) the keys get caught
>>> by
>>> the stack.
>>> Not sure if that helps you but I figure you might then be able to map the
>>> keys.
>>>
>>> Simon
>>>
>>>
>> That's jolly clever.
>>
>> However, at the risk of being a damp squib, I am wondering if there is a way
>> to do this inwith Livecode for 2 sound reasons:
>>
>> 1. vb script would tie one to Windows; as pretty well any script would tie
>> one to a specific operating system.
>>
>> 2. Livecode's greatest strength is that one develop something on one
>> platform and then deploy it all over the place.
>>
>> Richmond.
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Polling/probing the keyboard?

Geoff Canyon-4
In reply to this post by Richmond Mathewson-2
On Fri, Dec 20, 2013 at 9:49 AM, Richmond <[hidden email]>wrote:

> send "mouseUp" to btn "BTTN"
>
> but I cannot do this:
>
> send "keyDown" to key 112
>
> where 112 is the rawKeyDown value of that key on my keyboard.
>

In both cases (unless there's something really unusual about what you're
doing) it would be better to define a separate handler to do <whatever> and
then call that handler from within the mouseUp or rawKeyDown, so that when
you want that thing to happen *apart* from those instances, you can just
call the handler.
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Polling/probing the keyboard?

Richmond Mathewson-2
On 23/12/13 22:04, Geoff Canyon wrote:

> On Fri, Dec 20, 2013 at 9:49 AM, Richmond <[hidden email]>wrote:
>
>> send "mouseUp" to btn "BTTN"
>>
>> but I cannot do this:
>>
>> send "keyDown" to key 112
>>
>> where 112 is the rawKeyDown value of that key on my keyboard.
>>
> In both cases (unless there's something really unusual about what you're
> doing) it would be better to define a separate handler to do <whatever> and
> then call that handler from within the mouseUp or rawKeyDown, so that when
> you want that thing to happen *apart* from those instances, you can just
> call the handler.
> _______________________________________________
>

My problem is that I have a range of programs that allow end-users to
type material in
dead or rather unusual writing systems, using a "normal" keyboard.

Now on my UK English keyboard I happen to be using at the moment where I,
having been using US English keyboards for the last 20 years, expect to
see a '@'
there is a double-quote mark.

I want to be able to signal to end-users which key they should press on
their keyboards
to send a mouseUp to one of my virtual keys. Now what has a 'w' on my
keyboard may,
for the sake of argument have a 'у' on Professor Malenkov's keyboard and
'в' on
Professor Ustinov's keyboard; so putting a 'w' into a "window" on my
interface is not going to help
either of those imaginary professors at all.

So I need to get the keyDown char that a rawKeyDown of 119 will generate
on whosoever's
computer my program is running on.

I can, however, do this sort of thing:

on rawKeyDown RKD
put RKD into fld "rkd"
end rawKeyDown

on keyUp KD
put KD into fld "kd"
put fld "rkd" & " = " & fld "kd" into fld "equiv"
end keyUp

which I just worked out while answering your message, and feel "fairly
bl**dy stupid" that is took
me so long to work that one out!

Anyway, thousands of thanks for your posting as it kicked my lazy brain
into doing something vaguely constructive at last.

Richmond.


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Polling/probing the keyboard?

Richmond Mathewson-2
On 23/12/13 22:22, Richmond wrote:

> On 23/12/13 22:04, Geoff Canyon wrote:
>> On Fri, Dec 20, 2013 at 9:49 AM, Richmond
>> <[hidden email]>wrote:
>>
>>> send "mouseUp" to btn "BTTN"
>>>
>>> but I cannot do this:
>>>
>>> send "keyDown" to key 112
>>>
>>> where 112 is the rawKeyDown value of that key on my keyboard.
>>>
>> In both cases (unless there's something really unusual about what you're
>> doing) it would be better to define a separate handler to do
>> <whatever> and
>> then call that handler from within the mouseUp or rawKeyDown, so that
>> when
>> you want that thing to happen *apart* from those instances, you can just
>> call the handler.
>> _______________________________________________
>>
>
> My problem is that I have a range of programs that allow end-users to
> type material in
> dead or rather unusual writing systems, using a "normal" keyboard.
>
> Now on my UK English keyboard I happen to be using at the moment where I,
> having been using US English keyboards for the last 20 years, expect
> to see a '@'
> there is a double-quote mark.
>
> I want to be able to signal to end-users which key they should press
> on their keyboards
> to send a mouseUp to one of my virtual keys. Now what has a 'w' on my
> keyboard may,
> for the sake of argument have a 'у' on Professor Malenkov's keyboard
> and 'в' on
> Professor Ustinov's keyboard; so putting a 'w' into a "window" on my
> interface is not going to help
> either of those imaginary professors at all.
>
> So I need to get the keyDown char that a rawKeyDown of 119 will
> generate on whosoever's
> computer my program is running on.
>
> I can, however, do this sort of thing:
>
> on rawKeyDown RKD
> put RKD into fld "rkd"
> end rawKeyDown
>
> on keyUp KD
> put KD into fld "kd"
> put fld "rkd" & " = " & fld "kd" into fld "equiv"
> end keyUp
>
> which I just worked out while answering your message, and feel "fairly
> bl**dy stupid" that is took
> me so long to work that one out!
>
> Anyway, thousands of thanks for your posting as it kicked my lazy
> brain into doing something vaguely constructive at last.
>
> Richmond.
>

The main snag about this is that if one has a rawKeyUp routine in, say,
one's cardScript, it will block
a keyUp routine.

I would like to have a cardScript that contains rawKeyDown, keyDown and
rawKeyUp, and, just now
cannot quite see my way round that.

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Polling/probing the keyboard?

Jan Schenkel
You need to 'pass' the rawKeyDown, rawKeyUp and keyDown messages or LiveCode will stop processing the key event.
This allows you to discard illegal characters. Try the following:

 on rawKeyDown RKD
   put RKD into fld "rkd"
   pass rawKeyDown
 end rawKeyDown
 
 on keyUp KD
    put KD into fld "kd"
    put fld "rkd" & " = " & fld "kd" into fld "equiv"
end keyUp

HTH,

Jan Schenkel.

=====
Quartam Reports & PDF Library for LiveCode
www.quartam.com

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)

--------------------------------------------
On Mon, 12/23/13, Richmond <[hidden email]> wrote:

 Subject: Re: Polling/probing the keyboard?
 To: "How to use LiveCode" <[hidden email]>
 Date: Monday, December 23, 2013, 12:33 PM
 
 On 23/12/13 22:22, Richmond wrote:
 > On 23/12/13 22:04, Geoff Canyon wrote:
 >> On Fri, Dec 20, 2013 at 9:49 AM, Richmond <[hidden email]>wrote:
 >>
 >>> send "mouseUp" to btn "BTTN"
 >>>
 >>> but I cannot do this:
 >>>
 >>> send "keyDown" to key 112
 >>>
 >>> where 112 is the rawKeyDown value of that key
 on my keyboard.
 >>>
 >> In both cases (unless there's something really
 unusual about what you're
 >> doing) it would be better to define a separate
 handler to do <whatever> and
 >> then call that handler from within the mouseUp or
 rawKeyDown, so that when
 >> you want that thing to happen *apart* from those
 instances, you can just
 >> call the handler.
 >> _______________________________________________
 >>
 >
 > My problem is that I have a range of programs that
 allow end-users to type material in
 > dead or rather unusual writing systems, using a
 "normal" keyboard.
 >
 > Now on my UK English keyboard I happen to be using at
 the moment where I,
 > having been using US English keyboards for the last 20
 years, expect to see a '@'
 > there is a double-quote mark.
 >
 > I want to be able to signal to end-users which key they
 should press on their keyboards
 > to send a mouseUp to one of my virtual keys. Now what
 has a 'w' on my keyboard may,
 > for the sake of argument have a 'у' on Professor
 Malenkov's keyboard and 'в' on
 > Professor Ustinov's keyboard; so putting a 'w' into a
 "window" on my interface is not going to help
 > either of those imaginary professors at all.
 >
 > So I need to get the keyDown char that a rawKeyDown of
 119 will generate on whosoever's
 > computer my program is running on.
 >
 > I can, however, do this sort of thing:
 >
 > on rawKeyDown RKD
 > put RKD into fld "rkd"
 > end rawKeyDown
 >
 > on keyUp KD
 > put KD into fld "kd"
 > put fld "rkd" & " = " & fld "kd" into fld
 "equiv"
 > end keyUp
 >
 > which I just worked out while answering your message,
 and feel "fairly bl**dy stupid" that is took
 > me so long to work that one out!
 >
 > Anyway, thousands of thanks for your posting as it
 kicked my lazy brain into doing something vaguely
 constructive at last.
 >
 > Richmond.
 >
 
 The main snag about this is that if one has a rawKeyUp
 routine in, say, one's cardScript, it will block
 a keyUp routine.
 
 I would like to have a cardScript that contains rawKeyDown,
 keyDown and rawKeyUp, and, just now
 cannot quite see my way round that.
 
 _______________________________________________
 use-livecode mailing list
 [hidden email]
 Please visit this url to subscribe, unsubscribe and manage
 your subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Polling/probing the keyboard?

Richmond Mathewson-2
On 23/12/13 22:50, Jan Schenkel wrote:

> You need to 'pass' the rawKeyDown, rawKeyUp and keyDown messages or LiveCode will stop processing the key event.
> This allows you to discard illegal characters. Try the following:
>
>   on rawKeyDown RKD
>     put RKD into fld "rkd"
>     pass rawKeyDown
>   end rawKeyDown
>  
>   on keyUp KD
>      put KD into fld "kd"
>      put fld "rkd" & " = " & fld "kd" into fld "equiv"
> end keyUp
>
> HTH,
>
> Jan Schenkel.

Thank you very much; that does allow me to trap both rawKeyDown
and rawKeyUp for US English; but still mucks up badly on other keyboard
layouts.

Richmond.

>
> =====
> Quartam Reports & PDF Library for LiveCode
> www.quartam.com
>
> =====
> "As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)
>
> --------------------------------------------
> On Mon, 12/23/13, Richmond <[hidden email]> wrote:
>
>   Subject: Re: Polling/probing the keyboard?
>   To: "How to use LiveCode" <[hidden email]>
>   Date: Monday, December 23, 2013, 12:33 PM
>  
>   On 23/12/13 22:22, Richmond wrote:
>   > On 23/12/13 22:04, Geoff Canyon wrote:
>   >> On Fri, Dec 20, 2013 at 9:49 AM, Richmond <[hidden email]>wrote:
>   >>
>   >>> send "mouseUp" to btn "BTTN"
>   >>>
>   >>> but I cannot do this:
>   >>>
>   >>> send "keyDown" to key 112
>   >>>
>   >>> where 112 is the rawKeyDown value of that key
>   on my keyboard.
>   >>>
>   >> In both cases (unless there's something really
>   unusual about what you're
>   >> doing) it would be better to define a separate
>   handler to do <whatever> and
>   >> then call that handler from within the mouseUp or
>   rawKeyDown, so that when
>   >> you want that thing to happen *apart* from those
>   instances, you can just
>   >> call the handler.
>   >> _______________________________________________
>   >>
>   >
>   > My problem is that I have a range of programs that
>   allow end-users to type material in
>   > dead or rather unusual writing systems, using a
>   "normal" keyboard.
>   >
>   > Now on my UK English keyboard I happen to be using at
>   the moment where I,
>   > having been using US English keyboards for the last 20
>   years, expect to see a '@'
>   > there is a double-quote mark.
>   >
>   > I want to be able to signal to end-users which key they
>   should press on their keyboards
>   > to send a mouseUp to one of my virtual keys. Now what
>   has a 'w' on my keyboard may,
>   > for the sake of argument have a 'у' on Professor
>   Malenkov's keyboard and 'в' on
>   > Professor Ustinov's keyboard; so putting a 'w' into a
>   "window" on my interface is not going to help
>   > either of those imaginary professors at all.
>   >
>   > So I need to get the keyDown char that a rawKeyDown of
>   119 will generate on whosoever's
>   > computer my program is running on.
>   >
>   > I can, however, do this sort of thing:
>   >
>   > on rawKeyDown RKD
>   > put RKD into fld "rkd"
>   > end rawKeyDown
>   >
>   > on keyUp KD
>   > put KD into fld "kd"
>   > put fld "rkd" & " = " & fld "kd" into fld
>   "equiv"
>   > end keyUp
>   >
>   > which I just worked out while answering your message,
>   and feel "fairly bl**dy stupid" that is took
>   > me so long to work that one out!
>   >
>   > Anyway, thousands of thanks for your posting as it
>   kicked my lazy brain into doing something vaguely
>   constructive at last.
>   >
>   > Richmond.
>   >
>  
>   The main snag about this is that if one has a rawKeyUp
>   routine in, say, one's cardScript, it will block
>   a keyUp routine.
>  
>   I would like to have a cardScript that contains rawKeyDown,
>   keyDown and rawKeyUp, and, just now
>   cannot quite see my way round that.
>  
>   _______________________________________________
>   use-livecode mailing list
>   [hidden email]
>   Please visit this url to subscribe, unsubscribe and manage
>   your subscription preferences:
>   http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Polling/probing the keyboard?

Geoff Canyon-4
Would it be reasonable to have a setup screen where these messages are
trapped, and have the user hit enough keys on that screen for you to
identify the keyboard setup, and then proceed on to the screens where you
do the actual work without trapping those messages anymore.
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Polling/probing the keyboard?

Richmond Mathewson-2
On 26/12/13 02:22, Geoff Canyon wrote:
> Would it be reasonable to have a setup screen where these messages are
> trapped, and have the user hit enough keys on that screen for you to
> identify the keyboard setup, and then proceed on to the screens where you
> do the actual work without trapping those messages anymore.

That doesn't sound a bad idea at all, in theory.

But I'm not sure if I am prepared to spend ages building a database of all
the possible keyboard layouts on Mac, Win and Linux;
plus write the clunky code to deal with all of that.

Richmond.

> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode